diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 60722b5..e38491f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,6 +35,7 @@ jobs:
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- run: mvn test -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=SonarSource-Demos_junit-test-coverage-example_a1392355-783c-4434-ab85-06e7549a55ee -Dsonar.projectName='junit-test-coverage-example'
\ No newline at end of file
+ SONAR_HOST_URL:: ${{ secrets.SONAR_HOST_URL }}
+ run: mvn test -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey='SonarCloud-Demos_junit-test-coverage-example' -Dsonar.organization='sonarcloud-demos' -Dsonar.projectName='junit-test-coverage-example'
diff --git a/pom.xml b/pom.xml
index ab0f56c..ffa4424 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,8 @@
17
17
UTF-8
+ sonarcloud-demos
+ https://sonarcloud.io
./target/site/jacoco-unit-test-coverage-report/jacoco.xml
diff --git a/src/main/java/sonarsource/sonarsource_demos/CustomMath.java b/src/main/java/sonarsource/sonarsource_demos/CustomMath.java
new file mode 100644
index 0000000..6f15a0d
--- /dev/null
+++ b/src/main/java/sonarsource/sonarsource_demos/CustomMath.java
@@ -0,0 +1,8 @@
+package sonarsource.sonarsource_demos;
+
+public class CustomMath {
+ public int multiply(int a, int b) {
+ return a * b;
+ }
+
+}
diff --git a/src/test/java/sonarsource/sonarsource_demos/CustomMathTest.java b/src/test/java/sonarsource/sonarsource_demos/CustomMathTest.java
new file mode 100644
index 0000000..a2a038f
--- /dev/null
+++ b/src/test/java/sonarsource/sonarsource_demos/CustomMathTest.java
@@ -0,0 +1,12 @@
+package sonarsource.sonarsource_demos;
+
+import junit.framework.TestCase;
+
+public class CustomMathTest extends TestCase {
+
+ public void testF() {
+ CustomMath c = new CustomMath();
+ assertEquals(15, c.multiply(3,5));
+ }
+
+}