Running JUnit test in NetBeans gives NoSuchMethodError error on a method whose return type was changed

StackOverflow https://stackoverflow.com/questions/1772354

Question

I have a project in NetBeans with JUnit tests. I made a change to a method return type in a dependent project, and the app runs fine. But when I run the JUnit test from inside NetBeans I get a NoSuchMethodError. I made sure to clean and build.

Was it helpful?

Solution

The solution was to make a change (any change) to the class which was making the call to the changed method. I then saved the class, then undid the change and saved the class. Then running the JUnit test inside NetBeans worked. It seems like a bug with NetBeans caching. I've had strange issues like this before and I've had to close NetBeans, delete the NetBeans cache folder, and restart NetBeans. But it seems like making a change to that class (and then undoing it) was enough to fix the NetBeans cache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top