I am writing my spring-boot tests using rest-assured and these annotations on the test class -
java class 1:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ApplicationSErvice.class)
@WebAppConfiguration
@IntegrationTest("server.port:8083")
public class MyTestClass{
}
java class 2:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ApplicationSErvice.class)
@WebAppConfiguration
@IntegrationTest("server.port:8083")
public class MyTestAnotherClass{
}
Question here is , if I have to execute both the java classes on the teamcity one after the other in the form of executing integration tests,then is there a way that I can have the annotation just in one class so that once the service is up and running all the tests can execute or there is no way and I have to put the annotations in all the classes?
Actually, you can
You can do it using inheritance:
Class with all the configuration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ApplicationSErvice.class)
@WebAppConfiguration
@IntegrationTest("server.port:8083")
public class WebAppConfigTest {
}
First test class extending from WebAppConfigTest
public class MyTestClass extends WebAppConfigTest {
}
Second test class extending from WebAppConfigTest
public class MyTestClass extends WebAppConfigTest {
}
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