From b842d28fbd381b100617cca73105439f3a6efd31 Mon Sep 17 00:00:00 2001
From: Cole Gannaway
<156719330+cole-gannaway-sonarsource@users.noreply.github.com>
Date: Mon, 26 Aug 2024 08:45:54 -0500
Subject: [PATCH 1/6] Update project key in GH Action
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 60722b5..c511ea5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -37,4 +37,4 @@ jobs:
env:
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
+ run: mvn test -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=SonarCloud-Demos_junit-test-coverage-example -Dsonar.projectName='junit-test-coverage-example'
From e94a067f154410d7cc707cb8d4b8385677feb6c6 Mon Sep 17 00:00:00 2001
From: Cole Gannaway
<156719330+cole-gannaway-sonarsource@users.noreply.github.com>
Date: Mon, 26 Aug 2024 08:49:29 -0500
Subject: [PATCH 2/6] Update build.yml
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c511ea5..2505168 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,6 +35,6 @@ 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=SonarCloud-Demos_junit-test-coverage-example -Dsonar.projectName='junit-test-coverage-example'
From da40d78666d3bf2cd2be8c2bedfce177bd732915 Mon Sep 17 00:00:00 2001
From: Cole Gannaway
<156719330+cole-gannaway-sonarsource@users.noreply.github.com>
Date: Mon, 26 Aug 2024 08:51:18 -0500
Subject: [PATCH 3/6] Update build.yml
---
.github/workflows/build.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2505168..62445ee 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -37,4 +37,5 @@ jobs:
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=SonarCloud-Demos_junit-test-coverage-example -Dsonar.projectName='junit-test-coverage-example'
From 143f348e3d5d0ceb5de70d398c443177f3e594d8 Mon Sep 17 00:00:00 2001
From: Cole Gannaway
<156719330+cole-gannaway-sonarsource@users.noreply.github.com>
Date: Mon, 26 Aug 2024 08:57:46 -0500
Subject: [PATCH 4/6] Update build.yml
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 62445ee..e38491f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -38,4 +38,4 @@ jobs:
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=SonarCloud-Demos_junit-test-coverage-example -Dsonar.projectName='junit-test-coverage-example'
+ 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'
From 475e283d00d2f5edebd23da25fe51e829cc66986 Mon Sep 17 00:00:00 2001
From: Cole Gannaway
<156719330+cole-gannaway-sonarsource@users.noreply.github.com>
Date: Mon, 26 Aug 2024 09:04:27 -0500
Subject: [PATCH 5/6] Update pom.xml
---
pom.xml | 2 ++
1 file changed, 2 insertions(+)
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
From d7baf3c1fe04cbee0e22be9eb7720b567f8e28f7 Mon Sep 17 00:00:00 2001
From: Cole Gannaway
<156719330+cole-gannaway-sonarsource@users.noreply.github.com>
Date: Mon, 26 Aug 2024 09:15:42 -0500
Subject: [PATCH 6/6] added small files for pr
---
.../sonarsource/sonarsource_demos/CustomMath.java | 8 ++++++++
.../sonarsource_demos/CustomMathTest.java | 12 ++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 src/main/java/sonarsource/sonarsource_demos/CustomMath.java
create mode 100644 src/test/java/sonarsource/sonarsource_demos/CustomMathTest.java
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));
+ }
+
+}