Hello im a follower of this community years ago (helped me a lot :D), now im have some doubts/issues with integration test in spring boot using cucumber.
well i think its more about concepts, the integration test its for test the application (an api in this case) fully, so i developed few classes: BaseStepsDefinition, featureRunner and BookingApplicationTest.class
BaseStepsDefinition.class:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = BookingApplicationTest.class, webEnviroment = SpringBootTest.WebEnviroment.DEFINED_PORT)
public abstract class BaseStepsDefinition{
//all the stuff like @Steps , needed variables,restTemplate, methods etc..
}
FeatureRunner.class:
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features="src/test/resources/features"))
public class featureRunner{
//empty
}
BookingApplicationTest.class:
@Configuration
@EnableAutoConfiguration
public class BookingApplicationTest{
@Bean
public RestTemplate (){
return new RestTemplate();
}
}
So, with the annotation @SpringBootTest i can stand up the the application -> bookingApplicationTest, but later when i try to do some petitions to my api,this didn't answer me, always 404, but if i change the annotation @SpringBootTest with the classes parameter to BookingApplication (the real, in src/main) it works, i dont understand what is the purpose of @springboottest with classes annotation, should i add all the beans to the bookingApplicationTest?? i don't know the differences between stand up the BookingApplicationTest.class and the real one, how can i test properly?, can i test the real one? or maybe add @SpringBootApplication to my BookingTestApplication?or maybe add that main from BookingApplicationTest callin the real one:
public static void main(String[] args) {
SpringApplication.run(BookingApplication.class, args);
}
Any help would be greatly appreciated!!! Thank you!, if the response it's so good maybe i can send some eth/nanos to your address :) Seriously i was searching hours and hours, but dont understand correctly the applicationTest purpose and why isn't working...:S
Aucun commentaire:
Enregistrer un commentaire