jGrasp is an IDE brewed at Auburn University that offers visualization of coding data structures. It is a teaching tool for programming and data structure course using Java. This article shows how to configure and run JUnit test cases in jGrasp.
Before writing JUnit test cases, we need to configure jGrasp to use JUnit. The following illustrate the steps.
- Download JUnit from junit.org and save it somewhere e.g.
/home/me/apps. What you need are
- In jGrasp, click on Tools menu -> JUnit -> Configure
For Junit Home, click on Browse and choose where
junit.jaris stored (see figure).
- Click on OK
Now JUnit is configured and we’re ready to write unit tests.
Creating and Running Tests
The easiest way to create a JUnit test file is to open the class (java file) you want to test and click on the Create jUnit Test File button, as shown below. For example, if you have
Selector.java, clicking Create Test File button will create a test file named
Another way to create tests is to create your own test file. The following is a template of JUnit test file. If you create your own test file, make sure jGrasp knows it’s a test file. To do so you can drag your test file into test file group in the project.
After you have a test file, you can use the commands listed above to compile, run and debug your tests.