O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.1. Feature Testing

In feature testing, you create tests that verify that your parser produces the correct translation of text. For example, you should be able to test that an arithmetic parser evaluates "7 - 3 - 1" as 3. It is important to automate your tests, because during development a test that has previously passed can suddenly fail. For example, a new error in a tokenizer can cause a formerly effective arithmetic parser to fail.

You can write your own testing tools or use an existing framework. Several testing frameworks are available, including JUnit, which was used in writing the code for this book. JUnit, developed by Kent Beck and Erich Gamma, is freely available on the Internet.

Testing frameworks typically offer a standard way to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required