Reputation: 89
I am writing antlr4 grammar for a closed programming language. The application code i would be writing in python.
Now, i would like to unit/integration test all the grammar rules against the possible combinations of the language. For unit testing i am thinking of the below approaches. If anyone has worked on something similar can you give me directions on which method would be suitable ?
Any help for this would be very much appreciated.
Upvotes: 1
Views: 875
Reputation: 10008
I would keep the unit test simple (so that you can write a lot of them): parsing should expect 0 errors (or should expect n errors depending on your test).
Of course, you can print out something that will help you analyze quickly why a unit test is failing.
My opinion is that you should write your input files as the same time as your rules (don't write the all grammar and then all the unit tests)
As I was using Junit, I found Parameterized test used with Reflections very useful: I put all my test input files in one folder and need just one test file. Each time you will add or modify a rule or a test file, all your junit tests will be played without a need to update them.
Upvotes: 1