Skip to content

Commit

Permalink
Updated to final release of Testerra 2
Browse files Browse the repository at this point in the history
  • Loading branch information
martingrossmann committed Jun 27, 2022
1 parent 87bc5bc commit 54a0eb8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 25 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TeamCity Connector

<p align="center">
<a href="https://mvnrepository.com/artifact/io.testerra/teamcity-connector" title="MavenCentral"><img src="https://img.shields.io/maven-central/v/io.testerra/teamcity-connector/1?label=Maven%20Central"></a>
<a href="https://mvnrepository.com/artifact/io.testerra/teamcity-connector" title="MavenCentral"><img src="https://img.shields.io/maven-central/v/io.testerra/teamcity-connector/2?label=Maven%20Central"></a>
<a href="/../../commits/" title="Last Commit"><img src="https://img.shields.io/github/last-commit/telekom/testerra-teamcity-connector?style=flat"></a>
<a href="/../../issues" title="Open Issues"><img src="https://img.shields.io/github/issues/telekom/testerra-teamcity-connector?style=flat"></a>
<a href="./LICENSE" title="License"><img src="https://img.shields.io/badge/License-Apache%202.0-green.svg?style=flat"></a>
Expand Down Expand Up @@ -35,6 +35,7 @@ It will register automatically by using the Testerra ModuleHook.
| `1.0` | `1.0.0..1.8` |
| `1.1` | `1.9` |
| `2.0-RC-2` | `>= 2.0-RC-19` |
| `2.0` | `>= 2.0` |

### Usage

Expand All @@ -43,7 +44,7 @@ Include the following dependency in your project.
Gradle:

````groovy
implementation 'io.testerra:teamcity-connector:2.0-RC-2'
implementation 'io.testerra:teamcity-connector:2.0'
````

Maven:
Expand All @@ -53,7 +54,7 @@ Maven:
<dependency>
<groupId>io.testerra</groupId>
<artifactId>teamcity-connector</artifactId>
<version>2.0-RC-2</version>
<version>2.0</version>
</dependency>
````

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apply plugin: 'io.codearte.nexus-staging'

ext {
// Minimum required Testerra version
testerraCompileVersion = '2-SNAPSHOT'
testerraCompileVersion = '2.0'
// Unit tests use the latest Testerra version
testerraTestVersion = '[2,3-SNAPSHOT)'
moduleVersion = '2-SNAPSHOT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import com.google.inject.AbstractModule;
import eu.tsystems.mms.tic.testerra.plugins.teamcity.listener.TeamCityEventListener;
import eu.tsystems.mms.tic.testerra.plugins.teamcity.worker.TeamCityStatusReportWorker;
import eu.tsystems.mms.tic.testframework.common.Testerra;
import eu.tsystems.mms.tic.testframework.hooks.ModuleHook;
import eu.tsystems.mms.tic.testframework.report.TesterraListener;

/**
* Registering Workers for pushing status messages to teamcity while running a testerra test job
Expand All @@ -36,7 +36,7 @@ public class TeamCityHook extends AbstractModule implements ModuleHook {
@Override
public void init() {

EventBus eventBus = TesterraListener.getEventBus();
EventBus eventBus = Testerra.getEventBus();
eventBus.register(new TeamCityEventListener());
eventBus.register(new TeamCityStatusReportWorker());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@
package eu.tsystems.mms.tic.testerra.plugins.teamcity.listener;

import com.google.common.eventbus.Subscribe;

import static eu.tsystems.mms.tic.testframework.report.utils.ExecutionContextController.getCurrentExecutionContext;

import eu.tsystems.mms.tic.testerra.plugins.teamcity.TeamCityMessagePusher;
import eu.tsystems.mms.tic.testframework.common.Testerra;
import eu.tsystems.mms.tic.testframework.events.TestStatusUpdateEvent;
import eu.tsystems.mms.tic.testframework.report.ITestStatusController;
import eu.tsystems.mms.tic.testframework.report.TesterraListener;
import eu.tsystems.mms.tic.testframework.report.model.context.RunConfig;
import eu.tsystems.mms.tic.testframework.report.utils.IExecutionContextController;
import org.apache.commons.lang3.StringUtils;

/**
Expand All @@ -40,15 +46,17 @@ public class TeamCityEventListener implements TestStatusUpdateEvent.Listener {
@Override
@Subscribe
public void onTestStatusUpdate(TestStatusUpdateEvent event) {
String counterInfoMessage = TesterraListener.getTestStatusController().getCounterInfoMessage();
ITestStatusController statusController = Testerra.getInjector().getInstance(ITestStatusController.class);
IExecutionContextController executionContextController = Testerra.getInjector().getInstance(IExecutionContextController.class);

String counterInfoMessage = statusController.getCounterInfoMessage();

if (StringUtils.isBlank(counterInfoMessage)) {
counterInfoMessage = "Running";
}

final String teamCityMessage =
getCurrentExecutionContext().runConfig.getReportName() + " " + getCurrentExecutionContext().runConfig.RUNCFG + ": " +
counterInfoMessage;
RunConfig runConfig = executionContextController.getExecutionContext().getRunConfig();
final String teamCityMessage = runConfig.getReportName() + " " + runConfig.RUNCFG + ": " + counterInfoMessage;
messagePusher.updateProgressMessage(teamCityMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import eu.tsystems.mms.tic.testframework.events.ExecutionFinishEvent;
import eu.tsystems.mms.tic.testframework.report.FailureCorridor;
import eu.tsystems.mms.tic.testframework.report.ITestStatusController;
import eu.tsystems.mms.tic.testframework.report.TesterraListener;
import eu.tsystems.mms.tic.testframework.report.utils.ExecutionContextController;
import eu.tsystems.mms.tic.testframework.report.model.context.RunConfig;
import eu.tsystems.mms.tic.testframework.report.utils.IExecutionContextController;

/**
* Reports global build status to teamcity
Expand All @@ -43,11 +43,11 @@ public class TeamCityStatusReportWorker implements ExecutionFinishEvent.Listener
@Override
@Subscribe
public void onExecutionFinish(ExecutionFinishEvent event) {
ITestStatusController testStatusController = TesterraListener.getTestStatusController();
ITestStatusController statusController = Testerra.getInjector().getInstance(ITestStatusController.class);
RunConfig runConfig = Testerra.getInjector().getInstance(IExecutionContextController.class).getExecutionContext().getRunConfig();

String statusMessage = ExecutionContextController.getCurrentExecutionContext().runConfig.getReportName() + " " +
ExecutionContextController.getCurrentExecutionContext().runConfig.RUNCFG + ": ";
statusMessage += testStatusController.getCounterInfoMessage() + " ";
String statusMessage = runConfig.getReportName() + " " + runConfig.RUNCFG + ": ";
statusMessage += statusController.getCounterInfoMessage() + " ";

// There is a difference in build status depending on failure corridor active
// If corridor is active, we have to get these values and if corridor matches, we report a success
Expand All @@ -60,7 +60,7 @@ public void onExecutionFinish(ExecutionFinishEvent event) {
messagePusher.updateBuildStatus(TeamCityBuildStatus.FAILURE, statusMessage, false);
}
} else {
if (testStatusController.getTestsFailed() == 0) {
if (statusController.getTestsFailed() == 0) {
messagePusher.updateBuildStatus(TeamCityBuildStatus.SUCCESS, statusMessage, false);
} else {
messagePusher.updateBuildStatus(TeamCityBuildStatus.FAILURE, statusMessage, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ public void test07_VerifyTeamCityMessages() {
List<String> standardOutput = consoleCaptor.getStandardOutput();

// Assert all printed TeamCity messages
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: Running']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 1 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 1 Failed, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 1 Failed, 1 Skipped, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 1 Failed, 1 Expected Failed, 1 Skipped, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 1 Retried, 1 Failed, 1 Expected Failed, 1 Skipped, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test Report tcc-test: 1 Retried, 1 Failed, 1 Expected Failed, 1 Skipped, 3 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: Running']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 1 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 1 Failed, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 1 Failed, 1 Skipped, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 1 Failed, 1 Expected Failed, 1 Skipped, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 1 Retried, 1 Failed, 1 Expected Failed, 1 Skipped, 2 Passed']"));
Assert.assertTrue(standardOutput.contains("##teamcity[progressMessage 'Test report tcc-test: 1 Retried, 1 Failed, 1 Expected Failed, 1 Skipped, 3 Passed']"));

}

Expand Down

0 comments on commit 54a0eb8

Please sign in to comment.