To get experience using the JUnit testing library.
For this lab, you will add a JUnit test for an existing class, the Line class given here.
Your test should test each of the methods in the class.
- Download the Line.java file.
- Create a file called LineTest.java.
- Create tests for the getSlope, getDistance and parallelTo methods.
- Because of rounding errors, it is bad practice to test double values for exact equality.
To get around this, you can pass a small value (such as .0001) to assertEquals to be used as a delta.
- Each test should contain three different test cases.
- Copy the example TestRunner.java program (change the name of the test class).
When your program is done, email the code to firstname.lastname@example.org.
Copyright © 2018 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.