Skip to content

@Injectable instance gets replaced after first test in testclass #405

@patriziobruno

Description

@patriziobruno
  • Version of JMockit that was used: 1.30
  • JUnit version: 4.12
  • JDK 1.8 update 121
  • Ubuntu Linux 16.10 kernel 4.8.0-41-generic
  • org.springframework spring-test:4.3.7.RELEASE

I have a test class using spring-test to test a spring-mvc controller. The controller has a @Autowired field, filled by an @Injectable field in the test class. The injectable field has been initialized using a MockUp instance to mock some methods. The first test executed from the class works, when the second test is launched the injectable instance has changed and it's not using my mock anymore, that results in a NullPointerException in the controller class.

I've been able to run the tests by some hack (by making the injectable field static) with JDK 1.8 update 66 on Windows 2008.

I included a zip of the project to help reproduce the problem.

test.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions