覆盖单个弹簧引导测试的属性
2022-09-01 19:11:03
请考虑以下示例:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {
"some.property=valueA"
})
public class ServiceTest {
@Test
public void testA() { ... }
@Test
public void testB() { ... }
@Test
public void testC() { ... }
}
我正在使用注释的属性来设置此测试套件中所有测试的属性值。现在,我想为其中一个测试(假设)设置此属性的另一个值,而不会影响其他测试。我怎样才能做到这一点?我已经阅读了Spring Boot文档的“测试”一章,但我没有找到任何与我的用例相匹配的东西。SpringBootTest
properties
some.property
testC