I'm setting up tests with TestNG in an Eclipse project, but I get a strange error: When I try to generate a test class from a business class, I get a popup with a message saying "Grid not editable" (title) "The compilation unit is not compilable, or is not a sublcass of junit.framework.TestCase. Fix and tyr again" (body). Somehow, Eclipse seems to think I want to create JUnit classes, and I can't get why. Any clue?
Configuration:
You can execute your existing JUnit test cases using TestNG. TestNG can automatically recognize and run JUnit tests, so that you can use TestNG as a runner for all your existing tests and write new tests using TestNG.
All you have to do is to put JUnit library on the TestNG classpath, so it can find and use JUnit classes, change your test runner from JUnit to TestNG in Ant and then run TestNG in "mixed" mode. This way you can have all your tests in the same project, even in the same package, and start using TestNG.
JUnit simplifies the Unit testing process in Java with visual indicators and a Unit testing framework. JUnit use in the Eclipse IDE is convenient and quick to configure.
The error occurs because the JUnit library has not been configured for the project, but can be resolved using the following steps. 1. Right click on the Java project and select Build Path > Configure Build Path. 2.
Google CodePro Analytix, the newly open-sourced static analysis tool, is the cause of the problem. It creates a new default editor filter which tries to open each class which name ends with "Test" with its specific JUnit editor. The TestNG plugin for Eclipse, on the other side, generates test classes using the tested class name, with "Test" added at the end. So when you create a test class with the TestNG plugin, it's opened by default with CodePro Junit editor, which dispays an error popup saying the class is not a valid JUnit test class. Solution is to remove the editor filter in Eclipse Preferences:
Window -> Preferences ; General -> Editors -> File Associations
Select the *.java file type, pick Java Editor and click on the "Default" button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With