Unit Testing

Prerequisites

jMock
Download: http://www.jmock.org
jMock extends JUnit and adds the ability to create mock/stub objects useful to unit testing. DOC uses the older JMock 1 library.
jMock/CGLIB extension
Download: http://www.jmock.org
The jMock/CGLIB extension adds the ability to mock concrete classes. This can be downloaded from the jMock website.

DOC contains a large number of unit tests to ensure stability. Unfortunately, many of the tests are not written cleanly enough to be easily understood. That, however, does not detract from their usefulness.

As I was writing the unit tests, I was still learning about unit testing. As a result, you'll likely find the unit tests to be sub-par. A lot of documentation is missing and many of the tests are not actually "unit" tests--they test the system as a whole instead of testing individual units. Nevertheless, they have been very useful in ensuring the interpreter processes each instruction correctly. Because of its complexity, it's easy to break DOC when making changes, thus it's important to run the unit tests after making changes.

To run the unit test suite, open the project edu.louisiana.cacs.DetectObfuscation.unittests, right-click the file src/(default package)/AllTests.java, and select Run As->JUnit Test.