diff --git a/java-reporter-core/pom.xml b/java-reporter-core/pom.xml
index c1000ea..9f3669c 100644
--- a/java-reporter-core/pom.xml
+++ b/java-reporter-core/pom.xml
@@ -7,7 +7,7 @@
io.testomat
java-reporter-core
- 0.19.0
+ 0.19.1
jar
Testomat.io Reporter Core
diff --git a/java-reporter-core/src/main/java/io/testomat/core/constants/CommonConstants.java b/java-reporter-core/src/main/java/io/testomat/core/constants/CommonConstants.java
index 5bd7754..df0bf81 100644
--- a/java-reporter-core/src/main/java/io/testomat/core/constants/CommonConstants.java
+++ b/java-reporter-core/src/main/java/io/testomat/core/constants/CommonConstants.java
@@ -1,7 +1,7 @@
package io.testomat.core.constants;
public class CommonConstants {
- public static final String REPORTER_VERSION = "0.19.0";
+ public static final String REPORTER_VERSION = "0.19.1";
public static final String TESTS_STRING = "tests";
public static final String API_KEY_STRING = "api_key";
diff --git a/java-reporter-cucumber/pom.xml b/java-reporter-cucumber/pom.xml
index ffaead7..227c1ad 100644
--- a/java-reporter-cucumber/pom.xml
+++ b/java-reporter-cucumber/pom.xml
@@ -6,7 +6,7 @@
io.testomat
java-reporter-cucumber
- 0.10.0
+ 0.10.1
jar
Testomat.io Java Reporter Cucumber
@@ -51,7 +51,7 @@
io.testomat
java-reporter-core
- 0.19.0
+ 0.19.1
org.slf4j
diff --git a/java-reporter-junit/pom.xml b/java-reporter-junit/pom.xml
index 008462e..beea0a0 100644
--- a/java-reporter-junit/pom.xml
+++ b/java-reporter-junit/pom.xml
@@ -6,7 +6,7 @@
io.testomat
java-reporter-junit
- 0.10.0
+ 0.10.1
jar
Testomat.io Java Reporter JUnit
@@ -51,7 +51,7 @@
io.testomat
java-reporter-core
- 0.19.0
+ 0.19.1
org.slf4j
diff --git a/java-reporter-karate/pom.xml b/java-reporter-karate/pom.xml
index 9564b87..79631dc 100644
--- a/java-reporter-karate/pom.xml
+++ b/java-reporter-karate/pom.xml
@@ -6,7 +6,7 @@
io.testomat
java-reporter-karate
- 0.4.0
+ 0.4.1
jar
Testomat.io Java Reporter Karate
@@ -52,7 +52,7 @@
io.testomat
java-reporter-core
- 0.19.0
+ 0.19.1
io.karatelabs
diff --git a/java-reporter-testng/pom.xml b/java-reporter-testng/pom.xml
index 7c7a88b..097df77 100644
--- a/java-reporter-testng/pom.xml
+++ b/java-reporter-testng/pom.xml
@@ -6,7 +6,7 @@
io.testomat
java-reporter-testng
- 0.9.0
+ 0.9.1
jar
Testomat.io Java Reporter TestNG
@@ -47,7 +47,7 @@
io.testomat
java-reporter-core
- 0.19.0
+ 0.19.1
org.slf4j
diff --git a/java-reporter-testng/src/main/java/io/testomat/testng/extractor/TestNgParameterExtractor.java b/java-reporter-testng/src/main/java/io/testomat/testng/extractor/TestNgParameterExtractor.java
index 6f90edb..cf99710 100644
--- a/java-reporter-testng/src/main/java/io/testomat/testng/extractor/TestNgParameterExtractor.java
+++ b/java-reporter-testng/src/main/java/io/testomat/testng/extractor/TestNgParameterExtractor.java
@@ -28,18 +28,20 @@ public class TestNgParameterExtractor {
*/
public Object extractExample(ITestResult testResult) {
Object[] parameters = testResult.getParameters();
+ Map exampleMap = new HashMap<>();
+
if (parameters == null || parameters.length == 0) {
return null;
}
if (parameters.length == 1) {
- return parameters[0];
+ exampleMap.put("param0", parameters[0]);
+ return exampleMap;
}
Method method = testResult.getMethod().getConstructorOrMethod().getMethod();
String[] parameterNames = extractParameterNames(method, parameters.length);
- Map exampleMap = new HashMap<>();
for (int i = 0; i < parameters.length; i++) {
String paramName = i < parameterNames.length ? parameterNames[i] : "param" + i;
exampleMap.put(paramName, parameters[i]);
diff --git a/java-reporter-testng/src/test/java/io/testomat/testng/extractor/TestNgParameterExtractorTest.java b/java-reporter-testng/src/test/java/io/testomat/testng/extractor/TestNgParameterExtractorTest.java
index 9e6cf4d..4a49905 100644
--- a/java-reporter-testng/src/test/java/io/testomat/testng/extractor/TestNgParameterExtractorTest.java
+++ b/java-reporter-testng/src/test/java/io/testomat/testng/extractor/TestNgParameterExtractorTest.java
@@ -12,6 +12,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.testng.ITestClass;
import org.testng.ITestResult;
import org.testng.ITestNGMethod;
import org.testng.annotations.Parameters;
@@ -41,18 +42,20 @@ void shouldReturnNullWhenNoParameters() {
}
@Test
- @DisplayName("Should return single parameter directly")
- void shouldReturnSingleParameterDirectly() {
- // Given
+ @DisplayName("Should return map for a single parameter")
+ void shouldReturnMapForSingleParameter() {
ITestResult testResult = mock(ITestResult.class);
- String parameter = "testValue";
- when(testResult.getParameters()).thenReturn(new Object[]{parameter});
+ when(testResult.getParameters()).thenReturn(
+ new Object[]{"testValue"});
- // When
Object result = extractor.extractExample(testResult);
- // Then
- assertEquals(parameter, result);
+ assertNotNull(result);
+ assertTrue(result instanceof Map);
+
+ Map resultMap = (Map) result;
+ assertEquals(1, resultMap.size());
+ assertEquals("testValue", resultMap.get("param0"));
}
@Test
@@ -237,4 +240,157 @@ private void dummyMethodWithoutAnnotation(String param0, Integer param1) {
@SuppressWarnings("unused")
private void dummyMethodWithAnnotation(String username, Integer age) {
}
+
+ @Test
+ @DisplayName("Should preserve null parameter values")
+ void shouldPreserveNullParameterValues() throws Exception {
+ ITestResult testResult = mock(ITestResult.class);
+ ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
+ ConstructorOrMethod constructorOrMethod =
+ mock(ConstructorOrMethod.class);
+
+ Method method = TestNgParameterExtractorTest.class
+ .getDeclaredMethod(
+ "dummyMethodWithoutAnnotation",
+ String.class,
+ Integer.class);
+
+ when(testResult.getParameters()).thenReturn(
+ new Object[]{null, 123});
+ when(testResult.getMethod()).thenReturn(testNGMethod);
+ when(testNGMethod.getConstructorOrMethod())
+ .thenReturn(constructorOrMethod);
+ when(constructorOrMethod.getMethod()).thenReturn(method);
+
+ Object result = extractor.extractExample(testResult);
+
+ assertNotNull(result);
+ assertTrue(result instanceof Map);
+
+ Map resultMap = (Map) result;
+ assertTrue(resultMap.containsKey("param0"));
+ assertNull(resultMap.get("param0"));
+ assertEquals(123, resultMap.get("param1"));
+ }
+
+ @Test
+ @DisplayName("Should fall back when annotation has fewer names")
+ void shouldFallbackWhenAnnotationHasFewerNames() throws Exception {
+ ITestResult testResult = mock(ITestResult.class);
+ ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
+ ConstructorOrMethod constructorOrMethod =
+ mock(ConstructorOrMethod.class);
+
+ Method method = TestNgParameterExtractorTest.class
+ .getDeclaredMethod(
+ "dummyMethodWithIncompleteAnnotation",
+ String.class,
+ Integer.class,
+ boolean.class);
+
+ when(testResult.getParameters()).thenReturn(
+ new Object[]{"Alice", 30, true});
+ when(testResult.getMethod()).thenReturn(testNGMethod);
+ when(testNGMethod.getConstructorOrMethod())
+ .thenReturn(constructorOrMethod);
+ when(constructorOrMethod.getMethod()).thenReturn(method);
+
+ Object result = extractor.extractExample(testResult);
+
+ assertNotNull(result);
+ assertTrue(result instanceof Map);
+
+ Map resultMap = (Map) result;
+ assertEquals(3, resultMap.size());
+ assertEquals("Alice", resultMap.get("param0"));
+ assertEquals(30, resultMap.get("param1"));
+ assertEquals(true, resultMap.get("param2"));
+ }
+
+ @Test
+ @DisplayName("Should use annotation names in RID")
+ void shouldUseAnnotationNamesInRid() throws Exception {
+ ITestResult testResult = mock(ITestResult.class);
+ ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
+ ITestClass testClass = mock(ITestClass.class);
+ ConstructorOrMethod constructorOrMethod =
+ mock(ConstructorOrMethod.class);
+
+ Method method = TestNgParameterExtractorTest.class
+ .getDeclaredMethod(
+ "dummyMethodWithAnnotation",
+ String.class,
+ Integer.class);
+
+ when(testResult.getParameters()).thenReturn(
+ new Object[]{"Alice", 25});
+ when(testResult.getTestClass()).thenReturn(testClass);
+ when(testResult.getMethod()).thenReturn(testNGMethod);
+ when(testClass.getName()).thenReturn("com.example.TestClass");
+ when(testNGMethod.getMethodName()).thenReturn("testMethod");
+ when(testNGMethod.getConstructorOrMethod())
+ .thenReturn(constructorOrMethod);
+ when(constructorOrMethod.getMethod()).thenReturn(method);
+
+ String rid = extractor.generateRid(testResult);
+
+ assertEquals(
+ "com.example.TestClass.testMethod-username_Alice-age_25",
+ rid);
+ }
+
+ @Test
+ @DisplayName("Should handle empty string parameter")
+ void shouldHandleEmptyStringParameter() throws Exception {
+ ITestResult testResult = mock(ITestResult.class);
+ ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
+ ITestClass testClass = mock(ITestClass.class);
+ ConstructorOrMethod constructorOrMethod =
+ mock(ConstructorOrMethod.class);
+
+ Method method = TestNgParameterExtractorTest.class
+ .getDeclaredMethod(
+ "dummyMethodWithoutAnnotation",
+ String.class,
+ Integer.class);
+
+ when(testResult.getParameters()).thenReturn(new Object[]{""});
+ when(testResult.getTestClass()).thenReturn(testClass);
+ when(testResult.getMethod()).thenReturn(testNGMethod);
+ when(testClass.getName()).thenReturn("com.example.TestClass");
+ when(testNGMethod.getMethodName()).thenReturn("testMethod");
+ when(testNGMethod.getConstructorOrMethod())
+ .thenReturn(constructorOrMethod);
+ when(constructorOrMethod.getMethod()).thenReturn(method);
+
+ assertEquals(
+ "com.example.TestClass.testMethod-param0_h0",
+ extractor.generateRid(testResult));
+ }
+
+ @Test
+ @DisplayName("Should handle null parameters array")
+ void shouldHandleNullParametersArray() {
+ ITestResult testResult = mock(ITestResult.class);
+ ITestNGMethod testNGMethod = mock(ITestNGMethod.class);
+ ITestClass testClass = mock(ITestClass.class);
+
+ when(testResult.getParameters()).thenReturn(null);
+ when(testResult.getTestClass()).thenReturn(testClass);
+ when(testResult.getMethod()).thenReturn(testNGMethod);
+ when(testClass.getName()).thenReturn("com.example.TestClass");
+ when(testNGMethod.getMethodName()).thenReturn("testMethod");
+
+ assertEquals(
+ "com.example.TestClass.testMethod",
+ extractor.generateRid(testResult));
+ }
+
+
+
+ @Parameters({"username"})
+ @SuppressWarnings("unused")
+ private void dummyMethodWithIncompleteAnnotation(String username, Integer age, boolean active) {
+
+ }
}
diff --git a/testomat-allure-adapter/pom.xml b/testomat-allure-adapter/pom.xml
index 572e2e3..9b6acc2 100644
--- a/testomat-allure-adapter/pom.xml
+++ b/testomat-allure-adapter/pom.xml
@@ -6,7 +6,7 @@
io.testomat
testomat-allure-adapter
- 0.1.8
+ 0.1.9
jar
Testomat.io Testomat Allure adapter
@@ -67,7 +67,7 @@
io.testomat
java-reporter-core
- 0.19.0
+ 0.19.1
io.qameta.allure