From 4491af9d59be6ec5298d815efa860dac6879b937 Mon Sep 17 00:00:00 2001 From: Radislav Berkovich Date: Tue, 20 Apr 2021 12:29:27 +0300 Subject: [PATCH] us #1207024 : [TeamCity] Support Gherkin test result publishing in TeamCity --- .../teamcity/TeamCityPluginServicesImpl.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/com/hp/octane/plugins/jetbrains/teamcity/TeamCityPluginServicesImpl.java b/plugin/src/main/java/com/hp/octane/plugins/jetbrains/teamcity/TeamCityPluginServicesImpl.java index cacaa08..081c83c 100644 --- a/plugin/src/main/java/com/hp/octane/plugins/jetbrains/teamcity/TeamCityPluginServicesImpl.java +++ b/plugin/src/main/java/com/hp/octane/plugins/jetbrains/teamcity/TeamCityPluginServicesImpl.java @@ -47,6 +47,7 @@ import jetbrains.buildServer.util.ExceptionUtil; import jetbrains.buildServer.web.openapi.PluginDescriptor; import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.Logger; import java.io.DataInputStream; @@ -312,13 +313,21 @@ private List createTestList(SFinishedBuild build) { testResultStatus = TestRunResult.PASSED; } TestName fqTestName = testRun.getTest().getName(); - String pkgName = fqTestName.getPackageName(); - String className = fqTestName.getClassName(); - String testName = fqTestName.getTestMethodName(); - if (pkgName.length() > MAX_SIZE || - className.length() > MAX_SIZE || - testName.length() > MAX_SIZE) { - log.error("Test [" + fqTestName.toString() + "] excluded from test results sending to ALM Octane. One of its parameters (package name, class name or test name) exceeds max size of 255 chars length."); + String pkgName, className, testName; + if (fqTestName.isJavaLikeTestName()) { + pkgName = fqTestName.getPackageName(); + className = fqTestName.getClassName(); + testName = fqTestName.getTestMethodName(); + } else { + pkgName = StringUtils.strip(fqTestName.getSuite(), ": "); + className = null; + testName = fqTestName.getNameWithoutSuite(); + } + + if ((pkgName != null && pkgName.length() > MAX_SIZE) || + (className != null && className.length() > MAX_SIZE) || + (testName != null && testName.length() > MAX_SIZE)) { + log.error("Test [" + fqTestName + "] excluded from test results sending to ALM Octane. One of its parameters (package name, class name or test name) exceeds max size of 255 chars length."); } else { TestRun tr = dtoFactory.newDTO(TestRun.class) .setModuleName("")