简体   繁体   English

Spring-boot:如何通过使用rest-assured启动服务来执行多个测试类

[英]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.

相关问题 使用可放心的弹簧引导集成测试 - spring-boot integration testing using rest-assured Null 指针 向 spring-boot 测试注入放心的@Steps 时出现异常 - Null pointer Exception when injecting a rest-assured @Steps into spring-boot Test SpringBoot:如何使用保持稳定状态来测试服务是否已启动并正在运行 - SpringBoot: how to test if the service is up and running using rest-assured 如何使用spring-boot创建REST服务? - How to create a REST service with spring-boot? 集成测试期间服务未开始使用Spring-boot - Service not starting using Spring-boot during integration tests Mockito + Rest-Assured在Spring Boot REST MVC应用程序中未进行模拟(集成测试) - Mockito+ Rest-Assured not mocking in Spring Boot REST MVC application(Integration Testing) 如何编写REST控制器端点的单元测试而不在Spring-boot中模拟Service类 - How to write Unit test for REST Controller Endpoint without mocking Service class in Spring-boot 使用gradle运行spring-boot REST服务的集成测试 - Running integration tests for a spring-boot REST service using gradle 如何用gradle执行“spring-boot”项目中的所有测试用例? - How to execute all test case in the “spring-boot” project with gradle? 如何安全地制作spring-boot REST服务? - How to make spring-boot REST service with security?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM