7

I normally don't experience problem with JUnit annotation. But somehow today, with my new install of Netbeans 7.2, I am experiencing the following error when I use the @Before annotation:

annotation before is missing value for the attribute value

Does anyone know how to fix this?


UPDATE

I am writing a mavenized web-app. For the TestCase, when I try to import org.junit.Before the program instead imports org.aspectj.lang.annotation.Before

kasavbere
  • 5,721
  • 10
  • 48
  • 72

2 Answers2

11

Are you still getting the same error even after adding junit dependency in pom.xml?

Check to see that you are importing the right library i.e.

import org.junit.Before;

instead of

import org.aspectj.lang.annotation.Before;
joshuamabina
  • 1,340
  • 17
  • 25
ssbh
  • 141
  • 1
  • 6
8

Are you declarig a dependency to an up to date JUnit Version?

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <scope>test</scope>
</dependency>

You should be able to import the right class: org.junit.Before.

Anthony Accioly
  • 20,718
  • 8
  • 67
  • 109
  • 1
    I am very new to Maven. Is there a way to tell Maven to get the latest version of all dependencies by default? – kasavbere Sep 25 '12 at 02:18
  • 2
    kasavbere, although I deeply recommend you to use concrete library versions - so that new library updates do not break the build, or even worse, introduce subtle bugs at runtime - there are some approaches to do what you want. Refer to his post for further info: http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency. – Anthony Accioly Sep 25 '12 at 02:48