方法级别的@TestPropertySource注释替代方案

时间:2016-03-07 13:54:50

标签: java spring testing annotations spring-test

@TestPropertySource(locations="classpath:test.properties")
public class Aclass {}

是否有替代方法在方法中使用测试实例的属性。

@Test
public void aMethod(){}

2 个答案:

答案 0 :(得分:1)

例如使用元数据注释

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD) //triggering used in method.
@TestPropertySource(locations="classpath:test.properties")
@Test
public @interface testbase{}

并使用

@testbase
public void aMethod(){}

答案 1 :(得分:0)

仍然不可能,但是如果您希望遵循此功能,可以使用open issue