This is a simple white-box testing using junit tools.
Disclaimer: This testing is for educational purposes and not designated for production. The code and test cases may contain bugs.
- Java SE
- Junit
- Maven
- IDE (Preferably IntelliJ. Download IDE.)
- Maven setup (IntelliJ setup)
I assume that the IDE being used is IntelliJ Idea.
This java project is built using Maven
. Read more about Maven
here.
I already included the necessary configurations for this testing project inside pom.xml
.
-
Clone the repository -
git clone https://github.com/YU88John/whitebox-junit.git
-
Install necessary
junit
packages -mvn clean install
-
Compile the source file -
javac Utils.java
Note: The
JDK
used for Maven isJDK 17
. If any error comes up, ensure you have the sameJDK
version.- Check your
JDK
version -java -version
- If it's different, install
JDK 17
-sudo apt-get update
andsudo apt install openjdk-17-jdk
- (or) Not recommended but you can change
pom.xml
-<maven.compiler.source>17</maven.compiler.source>
replace17
with yourJDK
version.
- Check your
-
Right click on
UtilsTest.java
>Run 'UtilsTest'
testSumFile()
is written to be failed intentionally.