[英]Spring-boot : how to execute multiple test classes by just starting the service once using rest-assured
I am writing my spring-boot tests using rest-assured and these annotations on the test class - 我正在使用rest-assured和测试类的这些注释编写我的spring-boot测试 -
java class 1: java class 1:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ApplicationSErvice.class)
@WebAppConfiguration
@IntegrationTest("server.port:8083")
public class MyTestClass{
}
java class 2: 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? 这里的问题是,如果我必须以执行集成测试的形式一个接一个地执行teamcity上的两个java类,那么有没有一种方法可以让注释只在一个类中,这样一旦服务启动并且运行所有测试都可以执行或者没有办法,我必须在所有类中添加注释?
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
从
WebAppConfigTest
扩展的第一个测试类
public class MyTestClass extends WebAppConfigTest {
}
Second test class extending from WebAppConfigTest
从
WebAppConfigTest
扩展的第二个测试类
public class MyTestClass extends WebAppConfigTest {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.