Cannot run JUnit tests, after debugging in ANTLRWorks

In this semester I am taking the best course I have ever had: CIS706 – Translator Design aka “Compilers”. During this class, we are building a compiler for subset version of Java language. Homeworks looks like that: you get requirements and unit tests. Your score depends on number of passed tests. If all passed – you get 100%.

For development we use Java, JUnit and eclipse. To generate parser and lexer we use ANTLRWorks. The workflow is classic TDD style: you run tests, then try to fix bugs (e.g. your grammar) and run tests again.

Yesterday I spent almost 1 hour because I couldn’t rerun tests. When I clicked run, they started and…nothing. I needed to terminate, then tried again, but still nothing. Even the fundamental solution for all kinds of problems with your machine – turning it off and on again – didn’t help. I was trying to clean and build project, even remove .metadata directory. Still nothing.

Finally, I started debugging JUnit tests and I noticed, that it hangs on call to parser class generated by ANTLR. I removed it, regenerated…and run the tests! What happend? Debbuging in ANTLRWorks (which I did) locks or do some magic with generated files. That means: after each time you debug in ANTLRWorks, you need to regenerate parser/lexer.