Skip to content

Commit

Permalink
Improve testing experience (#62)
Browse files Browse the repository at this point in the history
Improve testing experience

* Remove allure to surefire-report
* Disable javascript test too slow through a system property
* Explain Disabled test
* Use test reporter in github action
  • Loading branch information
philippefichet authored Dec 16, 2023
1 parent 28af6fa commit af5c87d
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 52 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/build-on-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: macos-11

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
Expand All @@ -24,4 +24,14 @@ jobs:
node-version: '14'
- name: Test with Maven
run: mvn -Ddependency-check.skip=true -DhasNodeJSRuntime clean test
timeout-minutes: 10
timeout-minutes: 10
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
# Name of the check run which will be created
name: JUnit Tests
# Path to test results
path: target/surefire-reports/*.xml
# Format of test results
reporter: java-junit
10 changes: 10 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ jobs:
- name: Build with Maven
run: mvn clean package source:jar javadoc:jar verify spotless:check
timeout-minutes: 10
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
# Name of the check run which will be created
name: JUnit Tests
# Path to test results
path: target/surefire-reports/*.xml
# Format of test results
reporter: java-junit
10 changes: 10 additions & 0 deletions nbactions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>CUSTOM-surefire-report:report-only</actionName>
<displayName>surefire-report:report-only</displayName>
<goals>
<goal>surefire-report:report-only</goal>
</goals>
</action>
</actions>
104 changes: 56 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.philippefichet</groupId>
<artifactId>sonarlint4netbeans</artifactId>
Expand Down Expand Up @@ -76,20 +80,19 @@
<target>11</target>
</configuration>
</plugin>
<!-- Show https://docs.qameta.io/allure/ to understand configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
@{argLine} -Djava.util.logging.config.file=./src/test/resources/logging.properties -Dfile.encoding=UTF-8 -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<systemProperties>
<property>
<name>allure.results.directory</name>
<value>${project.build.directory}/allure-results</value>
<name>java.util.logging.config.file</name>
<value>./src/test/resources/logging.properties</value>
</property>
<property>
<name>file.encoding</name>
<value>UTF-8</value>
</property>
<property>
<name>junit.jupiter.extensions.autodetection.enabled</name>
Expand All @@ -99,15 +102,38 @@
<name>hasNodeJSRuntime</name>
<value>${hasNodeJSRuntime}</value>
</property>
<property>
<name>sonarlint4netbeans.test.skip.javascript</name>
<value>${sonarlint4netbeans.test.skip.javascript}</value>
</property>
</systemProperties>
<!-- https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html#surefire-extensions-and-reports-configuration-for-displayname -->
<!-- Surefire Extensions and Reports Configuration for @DisplayName -->
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<disable>false</disable>
<version>3.0</version>
<usePhrasedFileName>false</usePhrasedFileName>
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
</statelessTestsetReporter>
<consoleOutputReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5ConsoleOutputReporter">
<disable>false</disable>
<encoding>UTF-8</encoding>
<usePhrasedFileName>false</usePhrasedFileName>
</consoleOutputReporter>
<statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoReporter">
<disable>false</disable>
<usePhrasedFileName>false</usePhrasedFileName>
<usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
<usePhrasedClassNameInTestCaseSummary>true</usePhrasedClassNameInTestCaseSummary>
</statelessTestsetInfoReporter>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down Expand Up @@ -154,15 +180,6 @@
</dependency>
</dependencies>
</plugin>
<!-- https://docs.qameta.io/allure/ -->
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.12.0</version>
<configuration>
<reportVersion>${io.qameta.allure.version}</reportVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -225,20 +242,20 @@
</configuration>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>8.4.0</version>
<configuration>
<nodeAnalyzerEnabled>false</nodeAnalyzerEnabled>
<yarnAuditAnalyzerEnabled>false</yarnAuditAnalyzerEnabled>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>8.4.0</version>
<configuration>
<nodeAnalyzerEnabled>false</nodeAnalyzerEnabled>
<yarnAuditAnalyzerEnabled>false</yarnAuditAnalyzerEnabled>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
Expand Down Expand Up @@ -451,21 +468,12 @@
<version>${org.slf4j.version}</version>
<scope>test</scope>
</dependency>
<!-- https://docs.qameta.io/allure/ -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-junit5</artifactId>
<version>${io.qameta.allure.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.netbeans.version>RELEASE130</org.netbeans.version>
<aspectj.version>1.9.20.1</aspectj.version>
<assertj.version>3.23.1</assertj.version>
<org.mockito.version>4.8.1</org.mockito.version>
<io.qameta.allure.version>2.24.0</io.qameta.allure.version>
<junit-jupiter.version>5.10.0</junit-jupiter.version>
<!-- like as allure -->
<org.slf4j.version>1.7.36</org.slf4j.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.prefs.BackingStoreException;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -39,6 +40,11 @@
* @author FICHET Philippe &lt;philippe.fichet@laposte.net&gt;
*/
@Tag("javascript")
@DisabledIfSystemProperty(
named = "sonarlint4netbeans.test.skip.javascript",
matches = "true",
disabledReason = "Disabled because BundleUtils.extractFromClasspath(bundle, deployLocation); in BundleImpl is too slow (~60s.)"
)
public class SonarLintEngineImplJavascriptPluginTest {

@RegisterExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,11 @@ void getMergedExtraPropertiesAndReplaceVariables(Project project, Map<String, St
@Test
@DisplayName("Check to search default nodeJS installation")
@Tag("runtime")
@EnabledIfSystemProperty(named = "hasNodeJSRuntime", matches = "true", disabledReason = "This test require a nodeJS runtime")
@EnabledIfSystemProperty(
named = "hasNodeJSRuntime",
matches = "true",
disabledReason = "Disabled because test require a NodeJS runtime installed"
)
void tryToSearchDefaultNodeJS() throws IOException {
BiConsumer<Path, Version> biConsumerMocked = Mockito.mock(BiConsumer.class);
SonarLintUtils.tryToSearchDefaultNodeJS(
Expand Down

0 comments on commit af5c87d

Please sign in to comment.