Skip to content
Draft
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void onExecutionFinish(ExecutionFinishEvent event) {
}

private void finalizeExecutionContext() {
MethodRelations.flushAll();
// MethodRelations.flushAll();

ExecutionContext currentExecutionContext = contextController.getExecutionContext();
currentExecutionContext.updateEndTimeRecursive(new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private void finalizeMethod(MethodContext methodContext) {
*/
if (methodContext.getTestNgResult().isPresent()) {
ITestResult testResult = methodContext.getTestNgResult().get();
Method method = testResult.getMethod().getConstructorOrMethod().getMethod();
Throwable throwable = testResult.getThrowable();

if (testResult.getStatus() == ITestResult.CREATED && status == Status.FAILED) {
Expand All @@ -69,7 +68,7 @@ private void finalizeMethod(MethodContext methodContext) {
}

// announce to run context
MethodRelations.announceRun(method, methodContext);
MethodRelations.announceRun(methodContext);
}
methodContext.updateEndTimeRecursive(new Date());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
import eu.tsystems.mms.tic.testframework.events.ContextUpdateEvent;
import eu.tsystems.mms.tic.testframework.logging.Loggable;
import eu.tsystems.mms.tic.testframework.report.FailureCorridor;
import eu.tsystems.mms.tic.testframework.report.Status;
import eu.tsystems.mms.tic.testframework.report.utils.TestNGContextNameGenerator;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.DataProvider;

import java.lang.reflect.Method;
import java.util.Arrays;
Expand Down Expand Up @@ -127,14 +126,7 @@ private MethodContext getMethodContext(

MethodContext methodContext;
if (!found.isPresent()) {
MethodContext.Type methodType;

if (testNGMethod.isTest()) {
methodType = MethodContext.Type.TEST_METHOD;
} else {
methodType = MethodContext.Type.CONFIGURATION_METHOD;
}

MethodContext.Type methodType = getMethodContextType(testNGMethod);
methodContext = new MethodContext(methodContextName, methodType, this);
methodContext.setTestNgResult(testResult);
methodContext.setParameterValues(testResult.getParameters());
Expand Down Expand Up @@ -174,6 +166,25 @@ private MethodContext getMethodContext(
return methodContext;
}

private MethodContext.Type getMethodContextType(ITestNGMethod method) {
if (method.getConstructorOrMethod().getMethod().getAnnotation(DataProvider.class) != null) {
return MethodContext.Type.DATA_PROVIDER;
}
return method.isTest() ? MethodContext.Type.TEST_METHOD
: method.isBeforeSuiteConfiguration() ? MethodContext.Type.CONFIGURATION_BEFORE_SUITE
: method.isBeforeTestConfiguration() ? MethodContext.Type.CONFIGURATION_BEFORE_TEST
: method.isBeforeClassConfiguration() ? MethodContext.Type.CONFIGURATION_BEFORE_CLASS
: method.isBeforeTestConfiguration() ? MethodContext.Type.CONFIGURATION_BEFORE_METHOD
: method.isBeforeGroupsConfiguration() ? MethodContext.Type.CONFIGURATION_BEFORE_GROUPS
: method.isBeforeMethodConfiguration() ? MethodContext.Type.CONFIGURATION_BEFORE_METHOD
: method.isAfterMethodConfiguration() ? MethodContext.Type.CONFIGURATION_AFTER_METHOD
: method.isAfterGroupsConfiguration() ? MethodContext.Type.CONFIGURATION_AFTER_GROUPS
: method.isAfterClassConfiguration() ? MethodContext.Type.CONFIGURATION_AFTER_CLASS
: method.isAfterTestConfiguration() ? MethodContext.Type.CONFIGURATION_AFTER_TEST
: method.isAfterSuiteConfiguration() ? MethodContext.Type.CONFIGURATION_AFTER_SUITE
: MethodContext.Type.CONFIGURATION_METHOD;
}

// public MethodContext safeAddSkipMethod(ITestResult testResult) {
// MethodContext methodContext = getMethodContext(testResult);
// methodContext.readErrors().findFirst().ifPresentOrElse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ public class MethodContext extends AbstractContext {

public enum Type {
TEST_METHOD,
CONFIGURATION_METHOD
CONFIGURATION_BEFORE_SUITE,
CONFIGURATION_BEFORE_TEST,
CONFIGURATION_BEFORE_CLASS,
CONFIGURATION_BEFORE_METHOD,
CONFIGURATION_BEFORE_GROUPS,
CONFIGURATION_AFTER_GROUPS,
CONFIGURATION_AFTER_METHOD,
CONFIGURATION_AFTER_CLASS,
CONFIGURATION_AFTER_TEST,
CONFIGURATION_AFTER_SUITE,
CONFIGURATION_METHOD, // only used as fallback
DATA_PROVIDER;
}

private ITestResult testResult;
Expand Down Expand Up @@ -157,7 +168,9 @@ public Stream<MethodContext> readDependsOnMethodContexts() {
}

public void addRelatedMethodContext(MethodContext relatedMethodContext) {
this.relatedMethodContexts.add(relatedMethodContext);
if (!this.relatedMethodContexts.contains(relatedMethodContext) && relatedMethodContext != this) {
this.relatedMethodContexts.add(relatedMethodContext);
}
}

public void addDependsOnMethod(MethodContext methodContext) {
Expand Down Expand Up @@ -266,11 +279,11 @@ public void addPriorityMessage(String msg) {
}

public boolean isConfigMethod() {
return methodType == Type.CONFIGURATION_METHOD;
return !isTestMethod();
}

public boolean isTestMethod() {
return !isConfigMethod();
return methodType == Type.TEST_METHOD;
}

public Status getStatus() {
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ test {
'src/test/resources/Integration.xml',
]

def smokeTest = findProperty("smoke")
if (smokeTest) {
s = ['src/test/resources/Smoke.xml']
def playground = findProperty("play")
if (playground) {
s = ['src/test/resources/Playground.xml']
}

def preTest = findProperty("pretest")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package eu.tsystems.mms.tic.testframework.playground;

import eu.tsystems.mms.tic.testframework.logging.Loggable;
import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;

public class AbstractTest extends TesterraTest implements Loggable {

@BeforeGroups(groups = "group1")
public void beforeGroup1() {

}

@BeforeSuite(alwaysRun = true)
public void beforeSuite() {
log().info("Before suite");
}
//
// @BeforeTest(alwaysRun = true)
// public void beforeTest() {
// log().info("Before test");
// }

// @AfterTest
// public void afterTest() {
// log().info("After test");
// }

@AfterGroups(groups = "group1")
public void afterGroup1() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ public void testDependsOnPassed() {
}

// breaks Testerra :-(
@Test(dependsOnMethods = {"non-existing-method"})
// @Test(dependsOnMethods = {"non-existing-method"})
public void testDependsOnInvalidMethod() {
}

@Test(dependsOnGroups = "passed")
public void testDependsOnGroups() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package eu.tsystems.mms.tic.testframework.playground;

import eu.tsystems.mms.tic.testframework.AbstractWebDriverTest;
import org.testng.annotations.Test;

public class DependsOnTests2 extends AbstractWebDriverTest {

// Can only be executed with class 'DependsOnTests'

@Test(dependsOnGroups = "passed")
public void testDependsOnGroupsInOtherClass() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package eu.tsystems.mms.tic.testframework.playground;

import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class DependsOnTests3 extends AbstractTest {


@BeforeClass(groups = "group1")
public void beforeGroupClass() {

}


@Test(groups = "group1")
public void test1Group1() {

}

@Test(groups = "group1")
public void test2Group1() {

}

@Test(groups = "group2")
public void test1Group2() {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package eu.tsystems.mms.tic.testframework.playground;

import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;

public class DependsOnTests4 extends AbstractTest {


@Test(groups = "group1")
public void test3Group1() {

}

@Test(groups = "group1")
public void test4Group1() {

}

@Test(groups = "group2")
public void test2Group2() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,43 @@

import eu.tsystems.mms.tic.testframework.annotations.Fails;
import eu.tsystems.mms.tic.testframework.testing.TesterraTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class SimplePassingTest extends TesterraTest {
public class SimplePassingTest extends AbstractTest {

@BeforeClass()
public void beforeClassPassingTest1() {
log().info("Before class 1");
}
//
// @BeforeClass()
// public void beforeClassPassingTest2() {
// log().info("Before class 2");
// }

@AfterClass()
public void afterClassPassingTest1() {
log().info("After class 1");
}

@BeforeMethod()
public void beforeMethodPassingTest1() {

}

// @BeforeMethod()
// public void beforeMethodPassingTest2() {
//
// }

@AfterMethod
public void afterMethodPassingTest1() {
}

@Test
public void testPassing() {
Expand Down
27 changes: 27 additions & 0 deletions integration-tests/src/test/resources/Playground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="playground" parallel="none" thread-count="20">

<test name="test1">
<groups>
<run>
<include name="group1"/>
</run>
</groups>
<classes>
<!-- <class name="eu.tsystems.mms.tic.testframework.test.common.PropertyManagerTest"></class>-->
<!-- <class name="eu.tsystems.mms.tic.testframework.playground.DependsOnTests">-->
<!-- <methods>-->
<!-- <include name="testPassed"/>-->
<!-- <include name="testPassed2"/>-->
<!-- </methods>-->
<!-- </class>-->
<!-- <class name="eu.tsystems.mms.tic.testframework.playground.DependsOnTests2"/>-->
<!-- <class name="eu.tsystems.mms.tic.testframework.playground.SimplePassingTest"/>-->
<!-- <class name="eu.tsystems.mms.tic.testframework.playground.SimpleFailingTest"/>-->
<class name="eu.tsystems.mms.tic.testframework.playground.DependsOnTests3"/>
<class name="eu.tsystems.mms.tic.testframework.playground.DependsOnTests4"/>
</classes>
</test>
</suite>

15 changes: 0 additions & 15 deletions integration-tests/src/test/resources/Smoke.xml

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading