Search code examples
junitteardown

Teardown of a int with JUnit 4


I was doing several Junit testing on a interface that I implemented. And in the set-up i declared a :

int counter = 0;

But in the tear down i can't do : counter = null;

It gives me a message "Type mismatch : cannot convert type from null to int"

How can I tear down my counter variable ?


Solution

  • You can't tear down primitives, null is a value just for objects.

    Change int for Integer or just omit tearing down that reference.