之前的注释缺少属性值的值

kas*_*ere 6 java junit netbeans

我通常不会遇到JUnit注释的问题.但不知怎的,今天,在我新安装的Netbeans 7.2中,当我使用@Before注释时遇到以下错误:

annotation before is missing value for the attribute value
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这一问题?


UPDATE

我正在写一个mavenized web-app.对于TestCase,当我尝试导入org.junit.Before程序而不是导入时org.aspectj.lang.annotation.Before

小智 9

即使在pom.xml.

检查您是否正在导入正确的库,即

import org.junit.Before;
Run Code Online (Sandbox Code Playgroud)

代替

import org.aspectj.lang.annotation.Before;
Run Code Online (Sandbox Code Playgroud)


Ant*_*oly 6

您是否声明对最新JUnit版本的依赖?

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

你应该能够导入正确的类:org.junit.Before.

  • kasavbere,尽管我强烈建议您使用具体的库版本 - 这样新的库更新就不会破坏构建,或者更糟糕的是,在运行时引入微妙的错误 - 有一些方法可以满足您的需求。请参阅他的帖子以获取更多信息:http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency。 (2认同)