Created
July 11, 2019 12:00
-
-
Save prule/194b946504f2b88624cfd659d4fc1a66 to your computer and use it in GitHub Desktop.
Intellij IDEA Template for a JUnit 5 / Spring boot integration test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end | |
#parse("File Header.java") | |
import org.junit.jupiter.api.AfterEach; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Test; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.test.context.TestPropertySource; | |
import static org.assertj.core.api.Assertions.assertThat; | |
@SpringBootTest | |
// @TestPropertySource(locations = "/application-xxx.properties") | |
// @ActiveProfiles({"simulator-s3"}) | |
public class ${NAME} { | |
// @Value("${}") private String value; | |
@BeforeEach | |
public void before() { | |
} | |
@AfterEach | |
public void after() { | |
} | |
@Test | |
public void test() throws Exception { | |
// setup | |
// execute | |
// verify | |
// assertThat(actual).isEqualTo(expected); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this template by going to Preferences > Editor > File and Code Templates, click the + sign - Name your template something like "Integration Test" and paste in the template content above.
You can then create a class using this template by selecting some in a java source directory in the Project pane and pressing Command-N (on MacOS) - your template will be listed (and you can filter the list if you start typing)
To support the spring boot tests you'll also need to set up a spring boot application by doing something like the following: