Skip to content

Commit

Permalink
Version 2023.01.16: Fixed proper place of screenshots on failed setup…
Browse files Browse the repository at this point in the history
…, test and teardown
  • Loading branch information
KMariusz committed Jan 16, 2023
1 parent bb498b7 commit 66c8fff
Show file tree
Hide file tree
Showing 13 changed files with 423 additions and 49 deletions.
6 changes: 3 additions & 3 deletions mrchecker-framework-modules/mrchecker-cli-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<artifactId>mrchecker-test-framework</artifactId>
<groupId>com.capgemini.mrchecker</groupId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</parent>

<artifactId>mrchecker-cli-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
<packaging>jar</packaging>
<name>MrChecker - CLI - Module</name>
<description>MrChecker CLI Module supports:
Expand Down Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mrchecker-core-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions mrchecker-framework-modules/mrchecker-core-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>mrchecker-test-framework</artifactId>
<groupId>com.capgemini.mrchecker</groupId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</parent>

<artifactId>mrchecker-core-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
<packaging>jar</packaging>
<name>MrChecker - Test core - Module</name>
<description>MrChecker Test Framework Core is responsible for:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ public interface ITestObserver {

void onTestFinish();

void onSetupFailure();

void onTeardownFailure();

void onTestClassFinish();

void addToTestExecutionObserver();

ModuleType getModuleType();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ public void onTestFailure() {
.getSimpleName());
}

@Override
public void onSetupFailure() {
BFLogger.logDebug("Page.onSetupFailure " + getClass()
.getSimpleName());
}

@Override
public void onTeardownFailure() {
BFLogger.logDebug("Page.onTeardownFailure " + getClass()
.getSimpleName());
}

@Override
public void onTestFinish() {
BFLogger.logDebug("Page.onTestFinish " + getClass()
Expand All @@ -39,4 +51,4 @@ public void onTestClassFinish() {
public final void addToTestExecutionObserver() {
TEST_EXECUTION_OBSERVER.addObserver(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,31 @@ public void beforeTestExecution(ExtensionContext context) {
.sendClassName();
logTestInfo("STARTED");
stopwatch.set(System.currentTimeMillis());
validateTestClassAndCallHook(context, BaseTest::setUp);
try {
validateTestClassAndCallHook(context, BaseTest::setUp);
} catch (Throwable throwable) {
observers.get()
.forEach(ITestObserver::onSetupFailure);
classObservers.get()
.forEach(ITestObserver::onSetupFailure);
throw throwable;
}
}

@Override
public void afterTestExecution(ExtensionContext context) {
stopwatch.set(System.currentTimeMillis() - stopwatch.get()); // end timing
logTestInfo("FINISHED");
printTimeExecutionLog();
validateTestClassAndCallHook(context, BaseTest::tearDown);
try {
validateTestClassAndCallHook(context, BaseTest::tearDown);
} catch (Throwable throwable) {
observers.get()
.forEach(ITestObserver::onTeardownFailure);
classObservers.get()
.forEach(ITestObserver::onTeardownFailure);
throw throwable;
}
}

private static void makeLogForTest() {
Expand Down Expand Up @@ -91,10 +107,6 @@ public void testSuccessful(ExtensionContext context) {
@Override
public void testFailed(ExtensionContext context, Throwable cause) {
logTestInfo("FAILED");
observers.get()
.forEach(ITestObserver::onTestFailure);
classObservers.get()
.forEach(ITestObserver::onTestFailure);
afterEach();
}

Expand Down Expand Up @@ -148,27 +160,47 @@ private String getFormattedTestDuration() {

@Override
public void handleBeforeAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
observers.get()
.forEach(ITestObserver::onSetupFailure);
classObservers.get()
.forEach(ITestObserver::onSetupFailure);
logExceptionInfo(context, throwable, "@BeforeAll");
}

@Override
public void handleBeforeEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
observers.get()
.forEach(ITestObserver::onSetupFailure);
classObservers.get()
.forEach(ITestObserver::onSetupFailure);
logExceptionInfo(context, throwable, "@BeforeEach");
}

@Override
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
observers.get()
.forEach(ITestObserver::onTestFailure);
classObservers.get()
.forEach(ITestObserver::onTestFailure);
logExceptionInfo(context, throwable, "@Test");
}

@Override
public void handleAfterEachMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
observers.get()
.forEach(ITestObserver::onTeardownFailure);
classObservers.get()
.forEach(ITestObserver::onTeardownFailure);
logExceptionInfo(context, throwable, "@AfterEach");
}

@Override
public void handleAfterAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable {
try {
observers.get()
.forEach(ITestObserver::onTeardownFailure);
classObservers.get()
.forEach(ITestObserver::onTeardownFailure);
logExceptionInfo(context, throwable, "@AfterAll");
} catch (Throwable e) {
if (DONT_CONSUME_EXCEPTION_IN_AFTERALL)
Expand Down
6 changes: 3 additions & 3 deletions mrchecker-framework-modules/mrchecker-database-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<artifactId>mrchecker-test-framework</artifactId>
<groupId>com.capgemini.mrchecker</groupId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</parent>

<artifactId>mrchecker-database-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
<packaging>jar</packaging>
<name>MrChecker - Database - Module</name>
<description>MrChecker Database Module:
Expand Down Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mrchecker-core-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</dependency>

<!-- JPA dependencies -->
Expand Down
8 changes: 4 additions & 4 deletions mrchecker-framework-modules/mrchecker-mobile-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>mrchecker-test-framework</artifactId>
<groupId>com.capgemini.mrchecker</groupId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</parent>

<artifactId>mrchecker-mobile-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
<packaging>jar</packaging>
<name>MrChecker - Mobile - Module</name>
<description>MrChecker Test Framework name supports:
Expand Down Expand Up @@ -52,12 +52,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mrchecker-core-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mrchecker-selenium-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</dependency>

<!--This dependency is necessary for Appium plugin. -->
Expand Down
6 changes: 3 additions & 3 deletions mrchecker-framework-modules/mrchecker-security-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>mrchecker-test-framework</artifactId>
<groupId>com.capgemini.mrchecker</groupId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</parent>

<artifactId>mrchecker-security-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
<packaging>jar</packaging>
<name>MrChecker - Security - Module</name>
<description>MrChecker Test Framework Security supports:
Expand Down Expand Up @@ -63,7 +63,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mrchecker-core-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</dependency>

<!-- Needed to perform all API calls -->
Expand Down
6 changes: 3 additions & 3 deletions mrchecker-framework-modules/mrchecker-selenium-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<artifactId>mrchecker-test-framework</artifactId>
<groupId>com.capgemini.mrchecker</groupId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</parent>

<artifactId>mrchecker-selenium-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
<packaging>jar</packaging>
<name>MrChecker - Selenium - Module</name>
<description>MrChecker Test Framework Selenium supports:
Expand Down Expand Up @@ -98,7 +98,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mrchecker-core-module</artifactId>
<version>2023.01.03</version>
<version>2023.01.16</version>
</dependency>

<!--This dependency is necessary for Selenium plugin. -->
Expand Down
Loading

0 comments on commit 66c8fff

Please sign in to comment.