Now, you can write a Unit Test case for Order Service under the src/test/resources package. The complete code for build configuration file is given below. You can create an executable JAR file, and run the Spring Boot application by using the following Maven or Gradle1 commands.
In the Package Explorer, select the java class you want to generate the Junit test for. Go to File -> New -> Junit Test Cases. Change the Source folder to point to the test using Browse (Note: It is better to separate the source code from the testing code) Change the Package based on the destination package you want.
Apologize as this might seems to be an useless act, but is there any way we can actually do junit test on Spring-Boot(1.3.8.RELEASE)'s Application.java which this class does nothing but to start a Spring-boot application?
Given below:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
try{
SpringApplication.run(Application.class, args);
}catch(Exception e){
//code here
}
}
}
Maybe i can try catching exception? but what else can i possibly test so that JUnit will test out SpringApplication.run()? any example is appreciated. Thank you all!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With