Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
// Download the code
checkout scm
// Compile the main class
sh 'javac -d target -sourcepath src/main/java src/main/java/com/example/math/Calculator.java'
}
}
stage('Test') {
steps {
// Compile the tests
sh 'javac -d target -cp target:junit-platform-console-standalone-1.4.0.jar src/test/java/com/example/math/TestCalculator.java'
// Run the tests
sh 'java -jar junit-platform-console-standalone-1.4.0.jar --class-path target --scan-class-path --reports-dir=target/surefire-reports/'
}
}
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ci-jenkins-junit
Continuous Integration with Jenkins: Repo using JUnit tests
4 changes: 4 additions & 0 deletions src/main/java/com/example/math/Calculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public int subtract(int a, int b) {
return a - b;
}

public int multiply(int a, int b) {
return a * b;
}

}
7 changes: 7 additions & 0 deletions src/test/java/com/example/math/TestCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ public void subtract() {
assertEquals(2, calculator.subtract(8, 6));
}

@Test
public void multiply() {
Calculator calculator = new Calculator();
assertEquals(30, calculator.multiply(5, 6));
assertEquals(5, calculator.multiply(5, 1));
}

}