| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| junit-project-3 [2008/10/25 08:57] – jtkorb | junit-project-3 [2008/10/25 09:20] (current) – jtkorb |
|---|
| ====== JUnit Testing in Project 3 ====== | ====== JUnit Testing in Project 3 ====== |
| |
| [[http://www.cs.purdue.edu/homes/cs190m/fall08/projects/project3-tests|Here]] are three JUnit classes to do unit testing on classes WordNode, WordList, and HashList. | Here are three JUnit classes to do unit testing on the [[http://www.cs.purdue.edu/homes/cs190m/fall08/projects/project3|Project 3]] classes ''WordNode'', ''WordList'', and ''HashList''. |
| |
| To use these classes, download them to your Project 3 source directory and launch them as JUnit test classes. | * ''WordNode'': ''[[http://www.cs.purdue.edu/homes/cs190m/fall08/projects/project3-tests/WordNodeTest.java|WordNodeTest.java]]'' |
| | * ''WordList'': ''[[http://www.cs.purdue.edu/homes/cs190m/fall08/projects/project3-tests/WordListTest.java|WordListTest.java]]'' |
| | * ''HashList'': ''[[http://www.cs.purdue.edu/homes/cs190m/fall08/projects/project3-tests/HashListTest.java|HashListTest.java]]'' |
| |
| To do this testing from the command line on Lore (or the MC cluster), you'll need to have the JUnit jar file in your CLASSPATH, as explained [here]. Or, you can use the ''javat'' command located in the /homes/cs190m/student-bin directory (which should be in your path). The ''javat'' command is just a short shell script: | To use these classes, download them to your Project 3 source directory and launch them as JUnit test classes. (How you do this depends on your IDE and environment.) |
| | |
| | For example, from the command line on Lore (or the MC cluster), you can use the ''javat'' command located in the ''/homes/cs190m/student_bin'' directory (which should be in your path). The ''javat'' command is just a short shell script that sets the ''CLASSPATH'' environment variable, compiles the given test class, and uses the JUnit ''TestRunner'' class to run it: |
| |
| #!/bin/sh | #!/bin/sh |
| java junit.textui.TestRunner $1 | java junit.textui.TestRunner $1 |
| |
| | Then, to run these three tests, you would type (at the UNIX command line prompt): |
| | |
| | $ javat WordNodeTest |
| | $ javat WordListTest |
| | $ javat HashListTest |
| | |
| | These three test cases report no errors when run against my version of Project 3, but I may have made some assumptions that you didn't. If you have questions, a suggestion, or find a mistake in this process, please send me [[jtk@cs.purdue.edu|email]]. |