diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e3dfff4..750ea25e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,7 @@ jobs: test-gradle: needs: check-label - if: ${{ needs.check-label.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' }} + # if: ${{ needs.check-label.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' }} name: ${{ matrix.project_name }} runs-on: ubuntu-latest strategy: @@ -63,69 +63,70 @@ jobs: - project_name: gradle-junit4 configuration_id: GRADLE_JUNIT4_CONFIGURATION_ID project_id: GRADLE_JUNIT4_PROJECT_ID - - project_name: gradle-junit5 - configuration_id: GRADLE_JUNIT5_CONFIGURATION_ID - project_id: GRADLE_JUNIT5_PROJECT_ID - - project_name: gradle-testng - configuration_id: GRADLE_TESTNG_CONFIGURATION_ID - project_id: GRADLE_TESTNG_PROJECT_ID + + # - project_name: gradle-junit5 + # configuration_id: GRADLE_JUNIT5_CONFIGURATION_ID + # project_id: GRADLE_JUNIT5_PROJECT_ID + # - project_name: gradle-testng + # configuration_id: GRADLE_TESTNG_CONFIGURATION_ID + # project_id: GRADLE_TESTNG_PROJECT_ID - - project_name: jbehave-gradle-junit5 - configuration_id: JBEHAVE_GRADLE_JUNIT5_CONFIGURATION_ID - project_id: JBEHAVE_GRADLE_JUNIT5_PROJECT_ID - - project_name: jbehave-gradle-junit4 - configuration_id: JBEHAVE_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: JBEHAVE_GRADLE_JUNIT4_PROJECT_ID - - project_name: jbehave-gradle-testng - configuration_id: JBEHAVE_GRADLE_TESTNG_CONFIGURATION_ID - project_id: JBEHAVE_GRADLE_TESTNG_PROJECT_ID + # - project_name: jbehave-gradle-junit5 + # configuration_id: JBEHAVE_GRADLE_JUNIT5_CONFIGURATION_ID + # project_id: JBEHAVE_GRADLE_JUNIT5_PROJECT_ID + # - project_name: jbehave-gradle-junit4 + # configuration_id: JBEHAVE_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: JBEHAVE_GRADLE_JUNIT4_PROJECT_ID + # - project_name: jbehave-gradle-testng + # configuration_id: JBEHAVE_GRADLE_TESTNG_CONFIGURATION_ID + # project_id: JBEHAVE_GRADLE_TESTNG_PROJECT_ID - - project_name: cucumber7-gradle-testng - configuration_id: CUCUMBER7_GRADLE_TESTNG_CONFIGURATION_ID - project_id: CUCUMBER7_GRADLE_TESTNG_PROJECT_ID - - project_name: cucumber7-gradle-junit4 - configuration_id: CUCUMBER7_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: CUCUMBER7_GRADLE_JUNIT4_PROJECT_ID - - project_name: cucumber7-gradle-junit5 - configuration_id: CUCUMBER7_GRADLE_JUNIT5_CONFIGURATION_ID - project_id: CUCUMBER7_GRADLE_JUNIT5_PROJECT_ID + # - project_name: cucumber7-gradle-testng + # configuration_id: CUCUMBER7_GRADLE_TESTNG_CONFIGURATION_ID + # project_id: CUCUMBER7_GRADLE_TESTNG_PROJECT_ID + # - project_name: cucumber7-gradle-junit4 + # configuration_id: CUCUMBER7_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: CUCUMBER7_GRADLE_JUNIT4_PROJECT_ID + # - project_name: cucumber7-gradle-junit5 + # configuration_id: CUCUMBER7_GRADLE_JUNIT5_CONFIGURATION_ID + # project_id: CUCUMBER7_GRADLE_JUNIT5_PROJECT_ID - - project_name: cucumber6-gradle-junit5 - configuration_id: CUCUMBER6_GRADLE_JUNIT5_CONFIGURATION_ID - project_id: CUCUMBER6_GRADLE_JUNIT5_PROJECT_ID - - project_name: cucumber6-gradle-junit4 - configuration_id: CUCUMBER6_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: CUCUMBER6_GRADLE_JUNIT4_PROJECT_ID - - project_name: cucumber6-gradle-testng - configuration_id: CUCUMBER6_GRADLE_TESTNG_CONFIGURATION_ID - project_id: CUCUMBER6_GRADLE_TESTNG_PROJECT_ID + # - project_name: cucumber6-gradle-junit5 + # configuration_id: CUCUMBER6_GRADLE_JUNIT5_CONFIGURATION_ID + # project_id: CUCUMBER6_GRADLE_JUNIT5_PROJECT_ID + # - project_name: cucumber6-gradle-junit4 + # configuration_id: CUCUMBER6_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: CUCUMBER6_GRADLE_JUNIT4_PROJECT_ID + # - project_name: cucumber6-gradle-testng + # configuration_id: CUCUMBER6_GRADLE_TESTNG_CONFIGURATION_ID + # project_id: CUCUMBER6_GRADLE_TESTNG_PROJECT_ID - - project_name: cucumber5-gradle-junit4 - configuration_id: CUCUMBER5_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: CUCUMBER5_GRADLE_JUNIT4_PROJECT_ID - - project_name: cucumber5-gradle-junit5 - configuration_id: CUCUMBER5_GRADLE_JUNIT5_CONFIGURATION_ID - project_id: CUCUMBER5_GRADLE_JUNIT5_PROJECT_ID - - project_name: cucumber5-gradle-testng - configuration_id: CUCUMBER5_GRADLE_TESTNG_CONFIGURATION_ID - project_id: CUCUMBER5_GRADLE_TESTNG_PROJECT_ID + # - project_name: cucumber5-gradle-junit4 + # configuration_id: CUCUMBER5_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: CUCUMBER5_GRADLE_JUNIT4_PROJECT_ID + # - project_name: cucumber5-gradle-junit5 + # configuration_id: CUCUMBER5_GRADLE_JUNIT5_CONFIGURATION_ID + # project_id: CUCUMBER5_GRADLE_JUNIT5_PROJECT_ID + # - project_name: cucumber5-gradle-testng + # configuration_id: CUCUMBER5_GRADLE_TESTNG_CONFIGURATION_ID + # project_id: CUCUMBER5_GRADLE_TESTNG_PROJECT_ID - - project_name: cucumber4-gradle-junit4 - configuration_id: CUCUMBER4_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: CUCUMBER4_GRADLE_JUNIT4_PROJECT_ID - - project_name: cucumber4-gradle-testng - configuration_id: CUCUMBER4_GRADLE_TESTNG_CONFIGURATION_ID - project_id: CUCUMBER4_GRADLE_TESTNG_PROJECT_ID + # - project_name: cucumber4-gradle-junit4 + # configuration_id: CUCUMBER4_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: CUCUMBER4_GRADLE_JUNIT4_PROJECT_ID + # - project_name: cucumber4-gradle-testng + # configuration_id: CUCUMBER4_GRADLE_TESTNG_CONFIGURATION_ID + # project_id: CUCUMBER4_GRADLE_TESTNG_PROJECT_ID - - project_name: selenide-gradle-junit5 - configuration_id: SELENIDE_GRADLE_JUNIT5_CONFIGURATION_ID - project_id: SELENIDE_GRADLE_JUNIT5_PROJECT_ID - - project_name: serenity2-gradle-junit4 - configuration_id: SERENITY2_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: SERENITY2_GRADLE_JUNIT4_PROJECT_ID - - project_name: serenity3-gradle-junit4 - configuration_id: SERENITY3_GRADLE_JUNIT4_CONFIGURATION_ID - project_id: SERENITY3_GRADLE_JUNIT4_PROJECT_ID + # - project_name: selenide-gradle-junit5 + # configuration_id: SELENIDE_GRADLE_JUNIT5_CONFIGURATION_ID + # project_id: SELENIDE_GRADLE_JUNIT5_PROJECT_ID + # - project_name: serenity2-gradle-junit4 + # configuration_id: SERENITY2_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: SERENITY2_GRADLE_JUNIT4_PROJECT_ID + # - project_name: serenity3-gradle-junit4 + # configuration_id: SERENITY3_GRADLE_JUNIT4_CONFIGURATION_ID + # project_id: SERENITY3_GRADLE_JUNIT4_PROJECT_ID env: TMS_CONFIGURATION_ID: ${{ secrets[matrix.configuration_id] }} TMS_PROJECT_ID: ${{ secrets[matrix.project_id] }} @@ -139,11 +140,14 @@ jobs: repository: testit-tms/api-validator-dotnet token: ${{ env.GITHUB_PAT }} path: api-validator-dotnet + ref: 'feat/java-runs' - name: Checkout java-examples uses: actions/checkout@v4 with: repository: testit-tms/java-examples path: java-examples + ref: 'fix/selenide-build' + token: ${{ env.GITHUB_PAT }} - name: Setup dotnet uses: actions/setup-dotnet@v4 with: @@ -160,22 +164,25 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} - name: Setup environment run: | - ./gradlew --no-daemon -DdisableSign=true publishToMavenLocal + chmod +x gradlew + ./gradlew --no-daemon -DdisableSign=true publishToMavenLocal dotnet build --configuration Debug --property WarningLevel=0 api-validator-dotnet pip install testit-cli - name: Create TestRun run: | - testit testrun create --token ${{ env.TMS_PRIVATE_TOKEN }} --output ${{ env.TEMP_FILE }} + testit testrun create --token ${{ env.TMS_PRIVATE_TOKEN }} --output ${{ env.TEMP_FILE }} --project-id=${{ env.TMS_PROJECT_ID }} --url=${{ env.TMS_URL }} echo "TMS_TEST_RUN_ID=$(<${{ env.TEMP_FILE }})" >> $GITHUB_ENV - name: Test run: | cd java-examples/${{ matrix.project_name }} chmod +x ./gradlew - ./gradlew test --no-daemon -DtmsUrl=${{ env.TMS_URL }} -DtmsPrivateToken=${{ env.TMS_PRIVATE_TOKEN }} -DtmsProjectId=${{ env.TMS_PROJECT_ID }} -DtmsConfigurationId=${{ env.TMS_CONFIGURATION_ID }} -DtmsAdapterMode=${{ env.TMS_ADAPTER_MODE }} -DtmsTestRunId=${{ env.TMS_TEST_RUN_ID }} -DtmsCertValidation=${{ env.TMS_CERT_VALIDATION }} || exit 0 + IS_GITHUB_ACTION=true ./gradlew test --no-daemon -DtmsUrl=${{ env.TMS_URL }} -DtmsPrivateToken=${{ env.TMS_PRIVATE_TOKEN }} -DtmsProjectId=${{ env.TMS_PROJECT_ID }} -DtmsConfigurationId=${{ env.TMS_CONFIGURATION_ID }} -DtmsAdapterMode=${{ env.TMS_ADAPTER_MODE }} -DtmsTestRunId=${{ env.TMS_TEST_RUN_ID }} -DtmsCertValidation=${{ env.TMS_CERT_VALIDATION }} || exit 0 - name: Validate run: | dotnet test --configuration Debug --no-build --logger:"console;verbosity=detailed" api-validator-dotnet + + # test-maven: # needs: check-label # if: ${{ needs.check-label.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch' }} diff --git a/.gitignore b/.gitignore index ba67b43f..e58d9a68 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build/ .gradle/ .vs/ -bin \ No newline at end of file +bin +.secrets \ No newline at end of file diff --git a/Readme.md b/Readme.md index 6334a6fd..6e60d215 100644 --- a/Readme.md +++ b/Readme.md @@ -28,3 +28,4 @@ Supported test frameworks : # 🚀 Warning Since 2.2.0 version: - If value from @WorkItemIds annotation not found in TMS then test result will NOT be uploaded. + diff --git a/gradle.properties b/gradle.properties index 32c29459..a3365ff6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,3 +9,4 @@ org.gradle.configureondemand=true kotlin.code.style=official kotlin.stdlib.default.dependency=false + diff --git a/testit-adapter-cucumber7/src/main/java/ru/testit/listener/BaseCucumber7Listener.java b/testit-adapter-cucumber7/src/main/java/ru/testit/listener/BaseCucumber7Listener.java index eb4d6b75..c3f1cf2e 100644 --- a/testit-adapter-cucumber7/src/main/java/ru/testit/listener/BaseCucumber7Listener.java +++ b/testit-adapter-cucumber7/src/main/java/ru/testit/listener/BaseCucumber7Listener.java @@ -110,6 +110,9 @@ private void testStarted(final TestCaseStarted event) { final String uuid = getTestCaseUuid(currentTestCase.get()); final String scenarioName = currentTestCase.get().getName(); + String className = tagParser.getClassName(); + String spaceName = tagParser.getNameSpace(); + final TestResult result = new TestResult() .setUuid(uuid) .setExternalId(tagParser.getExternalId()) @@ -117,8 +120,8 @@ private void testStarted(final TestCaseStarted event) { .setTitle(tagParser.getTitle()) .setDescription(tagParser.getDescription()) .setWorkItemIds(tagParser.getWorkItemIds()) - .setSpaceName(tagParser.getNameSpace()) - .setClassName(tagParser.getClassName()) + .setSpaceName(Utils.nullOnEmptyString(spaceName)) + .setClassName(Utils.nullOnEmptyString(className)) .setLabels(tagParser.getScenarioLabels()) .setLinkItems(tagParser.getScenarioLinks()) .setParameters(parameters) diff --git a/testit-adapter-jbehave/src/main/java/ru/testit/listener/ScenarioParser.java b/testit-adapter-jbehave/src/main/java/ru/testit/listener/ScenarioParser.java index 94240896..3a2f5b5c 100644 --- a/testit-adapter-jbehave/src/main/java/ru/testit/listener/ScenarioParser.java +++ b/testit-adapter-jbehave/src/main/java/ru/testit/listener/ScenarioParser.java @@ -3,6 +3,7 @@ import org.jbehave.core.model.Scenario; import org.jbehave.core.model.Story; import ru.testit.models.TestResult; +import ru.testit.services.Utils; import java.util.Map; @@ -21,8 +22,8 @@ static public TestResult parseScenario(final Story story, final Scenario scenari .setTitle(tagParser.getTitle()) .setDescription(tagParser.getDescription()) .setWorkItemIds(tagParser.getWorkItemIds()) - .setClassName(featureName) - .setSpaceName(nameSpace) + .setClassName(Utils.nullOnEmptyString(featureName)) + .setSpaceName(Utils.nullOnEmptyString(nameSpace)) .setLabels(tagParser.getLabels()) .setLinkItems(tagParser.getLinks()) .setParameters(parameters); diff --git a/testit-adapter-junit4/src/main/java/ru/testit/listener/BaseJunit4Listener.java b/testit-adapter-junit4/src/main/java/ru/testit/listener/BaseJunit4Listener.java index 51685f77..89ec55b0 100644 --- a/testit-adapter-junit4/src/main/java/ru/testit/listener/BaseJunit4Listener.java +++ b/testit-adapter-junit4/src/main/java/ru/testit/listener/BaseJunit4Listener.java @@ -109,6 +109,8 @@ protected void startTestCase(Description method, final String uuid) { String fullName = method.getClassName(); int index = fullName.lastIndexOf("."); String testNode = fullName + "." + method.getMethodName(); + String spaceName = Utils.extractNamespace(method, (index != -1) ? fullName.substring(0, index) : null); + String className = Utils.extractClassname(method, (index != -1) ? fullName.substring(index + 1) : fullName); final TestResult result = new TestResult() .setUuid(uuid) @@ -117,8 +119,8 @@ protected void startTestCase(Description method, final String uuid) { .setWorkItemIds(Utils.extractWorkItemId(method)) .setTitle(Utils.extractTitle(method)) .setName(Utils.extractDisplayName(method)) - .setClassName(Utils.extractClassname(method, (index != -1) ? fullName.substring(index + 1) : fullName)) - .setSpaceName(Utils.extractNamespace(method, (index != -1) ? fullName.substring(0, index) : null)) + .setClassName(ru.testit.services.Utils.nullOnEmptyString(className)) + .setSpaceName(ru.testit.services.Utils.nullOnEmptyString(spaceName)) .setLinkItems(Utils.extractLinks(method)) .setDescription(Utils.extractDescription(method)) .setExternalKey(testNode); diff --git a/testit-adapter-junit5/src/main/java/ru/testit/listener/BaseJunit5Listener.java b/testit-adapter-junit5/src/main/java/ru/testit/listener/BaseJunit5Listener.java index aa7a8b3a..6a838e21 100644 --- a/testit-adapter-junit5/src/main/java/ru/testit/listener/BaseJunit5Listener.java +++ b/testit-adapter-junit5/src/main/java/ru/testit/listener/BaseJunit5Listener.java @@ -220,6 +220,12 @@ public void interceptTestMethod( protected void startTestCase(Method method, final String uuid, Map parameters) { String testNode = method.getDeclaringClass().getCanonicalName() + "." + method.getName(); + String spaceNameValue = (method.getDeclaringClass().getPackage() == null) + ? null : method.getDeclaringClass().getPackage().getName(); + String spaceName = Utils.extractNamespace(method, + spaceNameValue, parameters); + String className = Utils.extractClassname(method, method.getDeclaringClass().getSimpleName(), parameters); + final TestResult result = new TestResult() .setUuid(uuid) .setLabels(Utils.extractLabels(method, parameters)) @@ -227,12 +233,8 @@ protected void startTestCase(Method method, final String uuid, Map extractWorkItemId(final Method atomicTest, Map extractLinks(final Method atomicTest, Map parameters) { final List links = new LinkedList<>(); final Links linksAnnotation = atomicTest.getAnnotation(Links.class); diff --git a/testit-java-commons/src/main/java/ru/testit/writers/Converter.java b/testit-java-commons/src/main/java/ru/testit/writers/Converter.java index 9048c61f..efa8e66c 100644 --- a/testit-java-commons/src/main/java/ru/testit/writers/Converter.java +++ b/testit-java-commons/src/main/java/ru/testit/writers/Converter.java @@ -70,11 +70,22 @@ public static AutoTestResultsForTestRunModel testResultToAutoTestResultsForTestR model.setMessage(result.getMessage()); model.setParameters(result.getParameters()); + boolean shouldShortenTrace = false; + String isAction = System.getenv("IS_GITHUB_ACTION"); + if (isAction != null && isAction.equals("true")) { + shouldShortenTrace = true; + } + Throwable throwable = result.getThrowable(); if (throwable != null) { model.setMessage(throwable.getMessage()); - model.setTraces(ExceptionUtils.getStackTrace(throwable)); + String trace = ExceptionUtils.getStackTrace(throwable); + // try on short trace + model.setTraces(shouldShortenTrace + ? trace.substring(0, Math.min(trace.length(), 100)) + : trace); } + return model; } diff --git a/testit-java-commons/src/main/java/ru/testit/writers/HttpWriter.java b/testit-java-commons/src/main/java/ru/testit/writers/HttpWriter.java index bea77d06..9c26cf29 100644 --- a/testit-java-commons/src/main/java/ru/testit/writers/HttpWriter.java +++ b/testit-java-commons/src/main/java/ru/testit/writers/HttpWriter.java @@ -74,12 +74,15 @@ private void writeTestRealtime(TestResult testResult) { List results = new ArrayList<>(); results.add(autoTestResultsForTestRunModel); + List ids = apiClient.sendTestResults(config.getTestRunId(), results); + testResults.put(testResult.getUuid(), ids.get(0)); } catch (ApiException e) { LOGGER.error("Can not write the autotest: " + (e.getMessage())); } } + private AutoTestPostModel prepareToCreateAutoTest(TestResult testResult) throws ApiException { if (LOGGER.isDebugEnabled()) { @@ -285,6 +288,7 @@ private void updateTestResults(MainContainer container) { UUID testResultId = testResults.get(test.getUuid()); TestResultResponse resultModel = apiClient.getTestResult(testResultId); + TestResultUpdateV2Request model = Converter.testResultToTestResultUpdateModel(resultModel); model.setSetupResults(beforeResultFinish); model.setTeardownResults(afterResultFinish);