Exercise 2
info
This is an in-class exercise. An exercise page like this one will contain a brief description but is intended to be supplemented by discussion during our meeting time. Complete the exercise to the best of your ability in the time given. Feel free to talk with other students as you work, and do not be afraid to ask questions. Aim to complete as much as possible during our meeting, but you need not hand it in.
#
Learning ObjectivesObjectives
This exercise should help you:
- Blackbox testing techniques:
- Equivalence partitining,
- boundary analysis,
- Error guessing
- More practice with implementing test cases in JUnit
#
Task 1Answer the following questions for the method intersection()
below:
- Does the characteristic "Validity of s1" satisfy the completeness property? If not, give a value for s1 that does not fit in any block.
- Does the characteristic "Validity of s1" satisfy the disjointness property? If not, give a value for s1 that fits in more than one block.
- Does the characteristic "Relation between s1 and s2" satisfy the completeness property? If not, give a pair of values for s1 and s2 that does not fit in any block.
- Does the characteristic "Relation between s1 and s2" satisfy the disjointness property? If not, give a pair of values for s1 and s2 that fits in more than one block.
#
Task 2- Do a git pull on the course public repo and locate a file named
jhu-triangle-0.1.0.jar
underex2
folder. The idea is to import thisjar
file into your Java project so that you can test a function namedtriangle
located in a class namedTriangle
inside thisjar
file. In Intellij, follow these steps:
- Create a new Java Gradle project and make sure
build.gradle
is set up properly to use JUnit. If needed, see exercise 1 to see instruction how to do so. - Go To
build.gradle
and add the following underdependencies
:
- Create a folder in your project named
libs
and place the downloaded jar file i.e.jhu-triangle-0.1.0.jar
. Now, you can create a test class undersrc/test/java
and start testing triangle function. You'd need to add thisimport
to your test class file:
- Applying the blackbox testing techniques we have talked about in class, try to "black-box" test the
triangle
function as thoroughly as possible in a systematic way and see if you can find any faults. Here is the "Javadoc style" specs forTriangle.triangle
function:
HINT 1
There are are at least three faults in Triangle.triangle
.
HINT 2
If you have difficulty downloading the above jar
file, right click on the link and select Save link as
.
HINT 3
Do not underestimate the power of boundary analysis and error guessing!