16

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:

  • Eclipse 3.6.0
  • TestNG 5.14.10
jevon
  • 3,197
  • 3
  • 32
  • 40
Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124
  • So you do have the TestNG plugin for Eclipse installed? – mezmo Feb 28 '11 at 15:39
  • Yes, I installed it. You're right, I should have mentioned it. – Alexis Dufrenoy Feb 28 '11 at 16:06
  • 3
    Ok, I got it. It's Google CodePro. For some reason, it thinks that every class which name ends with "Test" is a JUnit test. So when I generate tests with the TestNG plugin, Eclipse open the test class with the CodePro Test Editor by default, and of course, it's not a valid JUnit test. I have to find a way to desactivate this. How lame... – Alexis Dufrenoy Feb 28 '11 at 17:45
  • 1
    I found a solution there: http://forums.instantiations.com/viewtopic.php?f=7&t=5535 – Alexis Dufrenoy Feb 28 '11 at 17:52

1 Answers1

53

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.

Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124