Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 68 additions & 61 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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] }}
Expand All @@ -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:
Expand All @@ -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' }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
build/
.gradle/
.vs/
bin
bin
.secrets
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ org.gradle.configureondemand=true

kotlin.code.style=official
kotlin.stdlib.default.dependency=false

Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ 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())
.setName(tagParser.getDisplayName())
.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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,21 @@ public void interceptTestMethod(
protected void startTestCase(Method method, final String uuid, Map<String, String> 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))
.setExternalId(Utils.extractExternalID(method, parameters))
.setWorkItemIds(Utils.extractWorkItemId(method, parameters))
.setTitle(Utils.extractTitle(method, parameters, true))
.setName(Utils.extractDisplayName(method, parameters))
.setClassName(Utils.extractClassname(method, method.getDeclaringClass().getSimpleName(), parameters))
.setSpaceName(Utils.extractNamespace(method,
(method.getDeclaringClass().getPackage() == null)
? null : method.getDeclaringClass().getPackage().getName(),
parameters)
)
.setClassName(Utils.nullOnEmptyString(className))
.setSpaceName(Utils.nullOnEmptyString(spaceName))
.setLinkItems(Utils.extractLinks(method, parameters))
.setDescription(Utils.extractDescription(method, parameters))
.setParameters(parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,23 @@ protected void startTestCase(final ITestResult testResult,
String testNode = testResult.getInstanceName() + "." + testResult.getName();

Method method = testResult.getMethod().getConstructorOrMethod().getMethod();

String spaceNameValue = ((method.getDeclaringClass().getPackage() == null
|| method.getDeclaringClass().getPackage().getName().equals(""))
? 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))
.setExternalId(Utils.extractExternalID(method, parameters))
.setWorkItemIds(Utils.extractWorkItemId(method, parameters))
.setTitle(Utils.extractTitle(method, parameters, true))
.setName(Utils.extractDisplayName(method, parameters))
.setClassName(Utils.extractClassname(method, method.getDeclaringClass().getSimpleName(), parameters))
.setSpaceName(Utils.extractNamespace(method,
((method.getDeclaringClass().getPackage() == null
|| method.getDeclaringClass().getPackage().getName().equals(""))
? null : method.getDeclaringClass().getPackage().getName()),
parameters))
.setClassName(Utils.nullOnEmptyString(className))
.setSpaceName(Utils.nullOnEmptyString(spaceName))
.setLinkItems(Utils.extractLinks(method, parameters))
.setDescription(Utils.extractDescription(method, parameters))
.setParameters(parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public static List<String> extractWorkItemId(final Method atomicTest, Map<String
return workItemIds;
}

public static String nullOnEmptyString(String value) {
if (value == "") {
return null;
}
return value;
}

public static List<LinkItem> extractLinks(final Method atomicTest, Map<String, String> parameters) {
final List<LinkItem> links = new LinkedList<>();
final Links linksAnnotation = atomicTest.getAnnotation(Links.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ private void writeTestRealtime(TestResult testResult) {

List<AutoTestResultsForTestRunModel> results = new ArrayList<>();
results.add(autoTestResultsForTestRunModel);

List<UUID> 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()) {
Expand Down Expand Up @@ -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);
Expand Down
Loading