This is an automated email from the ASF dual-hosted git repository.
yamer pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git
The following commit(s) were added to refs/heads/main by this push:
new 2e62485774 kie-issues#1678: Adapt Test Scenario Runner to JUnit 5 Test
Engine (#3929)
2e62485774 is described below
commit 2e624857748488a08b8262d9392718280cefd37a
Author: Yeser Amer <[email protected]>
AuthorDate: Fri May 23 14:19:57 2025 +0200
kie-issues#1678: Adapt Test Scenario Runner to JUnit 5 Test Engine (#3929)
* WIP
* Minor
* Minor
* Minor
---
drools/kogito-scenario-simulation/README.md | 16 ++--
drools/kogito-scenario-simulation/pom.xml | 23 ++----
.../soup/project/datamodel/imports/HasImports.java | 30 -------
.../kie/soup/project/datamodel/imports/Import.java | 69 ----------------
.../soup/project/datamodel/imports/Imports.java | 95 ----------------------
.../runner/KogitoJunitActivator.java | 7 ++
...st.java => TestScenarioJunitActivatorTest.java} | 8 +-
.../src/test/resources/logback.xml | 38 +++++++++
kogito-build/kogito-dependencies-bom/pom.xml | 30 ++++---
9 files changed, 81 insertions(+), 235 deletions(-)
diff --git a/drools/kogito-scenario-simulation/README.md
b/drools/kogito-scenario-simulation/README.md
index ae65a8f0d7..a320d470c5 100644
--- a/drools/kogito-scenario-simulation/README.md
+++ b/drools/kogito-scenario-simulation/README.md
@@ -22,9 +22,6 @@ Kogito Test Scenario runner
This module is a wrapper for Kogito of test scenario runner from `drools` repo.
-It contains a JUnit runner to make it possible to run `*.scesim` files via
Maven build.
-
-NOTE: it works with JUnit 5 vintange engine
How to use
----------
@@ -39,18 +36,21 @@ If you have one or more `*.scesim` files in your project to
execute, add this de
</dependency>
```
-And then create `KogitoScenarioJunitActivatorTest.java` file in
`src/test/java/testscenario` with this content
+And then create `TestScenarioJunitActivatorTest.java` file in
`src/test/java/testscenario` with this content
```java
package testscenario;
+import org.drools.scenariosimulation.backend.runner.TestScenarioActivator;
+
/**
* KogitoJunitActivator is a custom JUnit runner that enables the execution of
Test Scenario files (*.scesim).
* This activator class, when executed, will load all scesim files available
in the project and run them.
- * Each row of the scenario will generate a test JUnit result. */
[email protected](org.kogito.scenariosimulation.runner.KogitoJunitActivator.class)
-public class KogitoScenarioJunitActivatorTest {
+ * Each row of the scenario will generate a test JUnit result.
+ */
+@TestScenarioActivator
+public class TestScenarioJunitActivatorTest {
}
```
-After that execute `mvn clean test` to execute it (you can also execute
`KogitoScenarioJunitActivatorTest` in your IDE)
\ No newline at end of file
+After that execute `mvn clean test` to execute it (you can also execute
`TestScenarioJunitActivatorTest` in your IDE)
\ No newline at end of file
diff --git a/drools/kogito-scenario-simulation/pom.xml
b/drools/kogito-scenario-simulation/pom.xml
index 9ec945b918..8c21e38fe2 100644
--- a/drools/kogito-scenario-simulation/pom.xml
+++ b/drools/kogito-scenario-simulation/pom.xml
@@ -107,12 +107,6 @@
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-scenario-simulation-api</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.kie.soup</groupId>
- <artifactId>kie-soup-project-datamodel-api</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
@@ -131,16 +125,6 @@
<artifactId>jackson-databind</artifactId>
</exclusion>
- <!-- KIE soup -->
- <exclusion>
- <groupId>org.kie.soup</groupId>
- <artifactId>kie-soup-commons</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.kie.soup</groupId>
- <artifactId>kie-soup-project-datamodel-api</artifactId>
- </exclusion>
-
<!-- MVEL support -->
<exclusion>
<groupId>org.drools</groupId>
@@ -167,5 +151,12 @@
</exclusions>
</dependency>
+
+ <!-- For unit test logging: configure in
src/test/resources/logback.xml -->
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/HasImports.java
b/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/HasImports.java
deleted file mode 100644
index fc74e6353e..0000000000
---
a/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/HasImports.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.kie.soup.project.datamodel.imports;
-
-/**
- * Copied from kie-soup to avoid the dependency
- */
-public interface HasImports {
-
- Imports getImports();
-
- void setImports(final Imports imports);
-
-}
diff --git
a/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/Import.java
b/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/Import.java
deleted file mode 100644
index 5640438fb2..0000000000
---
a/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/Import.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.kie.soup.project.datamodel.imports;
-
-import java.util.Objects;
-
-/**
- * Copied from kie-soup to avoid the dependency
- */
-public class Import {
-
- private String type;
-
- public Import() {
-
- }
-
- public Import(String t) {
- this.type = t;
- }
-
- public Import(Class<?> clazz) {
- this(clazz.getName());
- }
-
- public String getType() {
- return this.type;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- // Must do instanceof check because there is a subtype of this class
in drools-workbench-models-datamodel-api
- if (!(o instanceof Import)) {
- return false;
- }
-
- Import anImport = (Import) o;
-
- return Objects.equals(type, anImport.type);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- @Override
- public int hashCode() {
- return type != null ? type.hashCode() : 0;
- }
-}
diff --git
a/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/Imports.java
b/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/Imports.java
deleted file mode 100644
index b9ecb9ddab..0000000000
---
a/drools/kogito-scenario-simulation/src/main/java/org/kie/soup/project/datamodel/imports/Imports.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.kie.soup.project.datamodel.imports;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Copied from kie-soup to avoid the dependency
- */
-public class Imports {
-
- private ArrayList<Import> imports = new ArrayList<>();
-
- public Imports() {
- }
-
- public Imports(final List<Import> imports) {
- this.imports = new ArrayList<>(imports);
- }
-
- public List<Import> getImports() {
- return imports;
- }
-
- public Set<String> getImportStrings() {
- Set<String> strings = new HashSet<>();
-
- for (Import item : imports) {
- strings.add(item.getType());
- }
-
- return strings;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- for (final Import i : imports) {
- sb.append("import ").append(i.getType()).append(";\n");
- }
-
- return sb.toString();
- }
-
- public void addImport(final Import item) {
- imports.add(item);
- }
-
- public void removeImport(final Import item) {
- imports.remove(item);
- }
-
- public boolean contains(final Import item) {
- return imports.contains(item);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Imports imports1 = (Imports) o;
-
- return Objects.equals(imports, imports1.imports);
- }
-
- @Override
- public int hashCode() {
- return imports != null ? imports.hashCode() : 0;
- }
-}
diff --git
a/drools/kogito-scenario-simulation/src/main/java/org/kogito/scenariosimulation/runner/KogitoJunitActivator.java
b/drools/kogito-scenario-simulation/src/main/java/org/kogito/scenariosimulation/runner/KogitoJunitActivator.java
index 3235f9d1d8..dc41bb42c1 100644
---
a/drools/kogito-scenario-simulation/src/main/java/org/kogito/scenariosimulation/runner/KogitoJunitActivator.java
+++
b/drools/kogito-scenario-simulation/src/main/java/org/kogito/scenariosimulation/runner/KogitoJunitActivator.java
@@ -19,8 +19,15 @@
package org.kogito.scenariosimulation.runner;
import org.drools.scenariosimulation.backend.runner.ScenarioJunitActivator;
+import org.drools.scenariosimulation.backend.runner.TestScenarioActivator;
import org.junit.runners.model.InitializationError;
+/**
+ * @deprecated This is the JUnit 4 implementation of Test Scenario, based on
+ * {@link org.junit.runner.Runner} JUnit 4 API. Replaced by {@link
TestScenarioActivator}
+ * Please replace {@code
@org.junit.runner.RunWith(ScenarioJunitActivator.class)} with
+ * {@code @TestScenarioActivator}
+ */
@Deprecated(since = "10.2", forRemoval = true)
public class KogitoJunitActivator extends ScenarioJunitActivator {
diff --git
a/drools/kogito-scenario-simulation/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java
b/drools/kogito-scenario-simulation/src/test/java/testscenario/TestScenarioJunitActivatorTest.java
similarity index 86%
rename from
drools/kogito-scenario-simulation/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java
rename to
drools/kogito-scenario-simulation/src/test/java/testscenario/TestScenarioJunitActivatorTest.java
index 6c754ad66a..8d8da584af 100644
---
a/drools/kogito-scenario-simulation/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java
+++
b/drools/kogito-scenario-simulation/src/test/java/testscenario/TestScenarioJunitActivatorTest.java
@@ -18,13 +18,13 @@
*/
package testscenario;
-import org.kogito.scenariosimulation.runner.KogitoJunitActivator;
+import org.drools.scenariosimulation.backend.runner.TestScenarioActivator;
/**
* KogitoJunitActivator is a custom JUnit runner that enables the execution of
Test Scenario files (*.scesim).
* This activator class, when executed, will load all scesim files available
in the project and run them.
* Each row of the scenario will generate a test JUnit result.
*/
[email protected](KogitoJunitActivator.class)
-public class KogitoScenarioJunitActivatorTest {
-}
\ No newline at end of file
+@TestScenarioActivator
+public class TestScenarioJunitActivatorTest {
+}
diff --git a/drools/kogito-scenario-simulation/src/test/resources/logback.xml
b/drools/kogito-scenario-simulation/src/test/resources/logback.xml
new file mode 100644
index 0000000000..58970c3a23
--- /dev/null
+++ b/drools/kogito-scenario-simulation/src/test/resources/logback.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+<configuration>
+
+ <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%date{HH:mm:ss.SSS} [%thread] %-5level %class{36}.%method:%line
- %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.kie" level="info"/>
+ <logger name="org.drools" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="consoleAppender" />
+ </root>
+
+</configuration>
diff --git a/kogito-build/kogito-dependencies-bom/pom.xml
b/kogito-build/kogito-dependencies-bom/pom.xml
index 34afd24b3e..a7851dc58b 100644
--- a/kogito-build/kogito-dependencies-bom/pom.xml
+++ b/kogito-build/kogito-dependencies-bom/pom.xml
@@ -123,16 +123,14 @@
<version.org.postgres>15.9-alpine3.20</version.org.postgres>
<!-- we align to version used by quarkus -->
<version.org.apache.avro>1.12.0</version.org.apache.avro>
- <version.org.assertj>3.24.2</version.org.assertj>
+ <version.org.assertj>3.27.3</version.org.assertj>
<version.org.glassfish.jaxb>4.0.4</version.org.glassfish.jaxb>
<version.org.json-unit-assertj>2.9.0</version.org.json-unit-assertj>
<version.org.hamcrest>2.2</version.org.hamcrest> <!-- else old version
coming from Mockito wins and breaks tests -->
- <version.org.junit>5.10.2</version.org.junit>
- <version.org.junit.jupiter>5.10.2</version.org.junit.jupiter>
- <version.org.junit.vintage>5.10.2</version.org.junit.vintage>
- <version.org.junit.platform>1.10.2</version.org.junit.platform><!--
otherwise Quarkus brings its own, silently disabling some tests -->
- <version.junit>4.13.2</version.junit>
- <version.org.mockito>5.8.0</version.org.mockito>
+ <version.org.junit>4.13.2</version.org.junit>
+ <version.org.junit.jupiter>5.12.2</version.org.junit.jupiter>
+ <version.org.junit.platform>1.12.2</version.org.junit.platform><!--
otherwise Quarkus brings its own, silently disabling some tests -->
+ <version.org.mockito>5.17.0</version.org.mockito>
<version.org.testcontainers>1.20.1</version.org.testcontainers>
<version.org.xmlunit-core>2.10.0</version.org.xmlunit-core>
<version.io.rest-assured>5.5.0</version.io.rest-assured>
@@ -477,6 +475,11 @@
<version>${version.org.awaitility}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.org.junit}</version>
+ </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
@@ -508,15 +511,16 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${version.org.junit.vintage}</version>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-launcher</artifactId>
+ <version>${version.org.junit.platform}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <version>${version.org.junit.jupiter}</version>
+ <scope>test</scope>
</dependency>
<dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]