我有一个很奇怪的问题。我的继承人方法JUnit:当使用注释测试方法时,测试忽略注释
@SomeAnnotation(value = "test")
public void doSomethink() {
..
}
当我用我的应用程序everythink工作正常(在调试调用方法doSomethink()
时,它也走了进去注解),但是当我运行测试像下面
@Test
public void testDoSomethink() {
service.doSomethink();
}
我的测试完全忽略注解并直接进入doSomethink
方法。我错过了一些思考?我认为那段代码就够了,但是如果你需要更多的话,请告诉我。
SomeAnnotation
package org.springframework.security.access.prepost;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface SomeAnnotation{
String value();
}
通过忽略我的意思是,通过测试运行时,它只是旁路注释像它甚至没有出现
“忽略注释”是什么意思?注释只是元数据,它们不能修改代码本身的行为。 – axtavt
这个注解是什么,它属于哪个库? – MaDa
更新的问题,THX反馈 – ojciecmatki