0

In my java spring mvc app, I am trying to reset a bunch of records for test with Junit. but in line:

@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)

It complains with:

ClassMode cannot be resolved to a variable

Update:

I have added

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>2.5</version>
</dependency>

but then it complains with other lines

@ActiveProfiles("test")
@Sql(scripts="requests-dataset.sql") 
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)

the error is:

    ActiveProfiles cannot be resolved to a type
Sql cannot be resolved to a type
Sql cannot be resolved to a type

1 Answer 1

1

First of all, the class name is DirtiesContext.ClassMode (it's a nested class of DirtiesContext).

Second, as any other class, it must be imported.

Third, as the javadoc shows, it exists since Spring 3.0. So you won't find it in Spring 2.5. Use the same version of spring-test as the version used for the rest of the spring framework libraries that you're using.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.