Upgrade to TestNG 6.11 (and Netty 4.1.9)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,10 +16,13 @@
|
||||
|
||||
package org.springframework.test.context.junit4;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.testng.ITestNGListener;
|
||||
import org.testng.TestNG;
|
||||
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestContext;
|
||||
@@ -32,9 +35,6 @@ import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import org.testng.ITestNGListener;
|
||||
import org.testng.TestNG;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
@@ -55,15 +55,18 @@ import static org.junit.Assert.*;
|
||||
public class FailingBeforeAndAfterMethodsTestNGTests {
|
||||
|
||||
protected final Class<?> clazz;
|
||||
|
||||
protected final int expectedTestStartCount;
|
||||
|
||||
protected final int expectedTestSuccessCount;
|
||||
|
||||
protected final int expectedFailureCount;
|
||||
|
||||
protected final int expectedFailedConfigurationsCount;
|
||||
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static Object[][] testData() {
|
||||
// @formatter:off
|
||||
return new Object[][] {
|
||||
{ AlwaysFailingBeforeTestClassTestCase.class.getSimpleName(), 1, 0, 0, 1 },
|
||||
{ AlwaysFailingAfterTestClassTestCase.class.getSimpleName(), 1, 1, 0, 1 },
|
||||
@@ -75,11 +78,12 @@ public class FailingBeforeAndAfterMethodsTestNGTests {
|
||||
{ FailingBeforeTransactionTestCase.class.getSimpleName(), 1, 0, 0, 1 },
|
||||
{ FailingAfterTransactionTestCase.class.getSimpleName(), 1, 1, 0, 1 }
|
||||
};
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
|
||||
public FailingBeforeAndAfterMethodsTestNGTests(String testClassName, int expectedTestStartCount,
|
||||
int expectedTestSuccessCount, int expectedFailureCount, int expectedFailedConfigurationsCount) throws Exception {
|
||||
|
||||
this.clazz = ClassUtils.forName(getClass().getName() + "." + testClassName, getClass().getClassLoader());
|
||||
this.expectedTestStartCount = expectedTestStartCount;
|
||||
this.expectedTestSuccessCount = expectedTestSuccessCount;
|
||||
@@ -87,26 +91,26 @@ public class FailingBeforeAndAfterMethodsTestNGTests {
|
||||
this.expectedFailedConfigurationsCount = expectedFailedConfigurationsCount;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore("Fails against TestNG 6.11")
|
||||
public void runTestAndAssertCounters() throws Exception {
|
||||
final TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
|
||||
final TestNG testNG = new TestNG();
|
||||
TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
|
||||
TestNG testNG = new TestNG();
|
||||
testNG.addListener((ITestNGListener) listener);
|
||||
testNG.setTestClasses(new Class<?>[] { this.clazz });
|
||||
testNG.setTestClasses(new Class<?>[] {this.clazz});
|
||||
testNG.setVerbose(0);
|
||||
testNG.run();
|
||||
|
||||
String name = this.clazz.getSimpleName();
|
||||
|
||||
assertEquals("tests started for [" + name + "] ==> ", this.expectedTestStartCount, listener.testStartCount);
|
||||
assertEquals("successful tests for [" + name + "] ==> ", this.expectedTestSuccessCount,
|
||||
listener.testSuccessCount);
|
||||
assertEquals("successful tests for [" + name + "] ==> ", this.expectedTestSuccessCount, listener.testSuccessCount);
|
||||
assertEquals("failed tests for [" + name + "] ==> ", this.expectedFailureCount, listener.testFailureCount);
|
||||
assertEquals("failed configurations for [" + name + "] ==> ", this.expectedFailedConfigurationsCount,
|
||||
listener.failedConfigurationsCount);
|
||||
assertEquals("failed configurations for [" + name + "] ==> ",
|
||||
this.expectedFailedConfigurationsCount, listener.failedConfigurationsCount);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
static class AlwaysFailingBeforeTestClassTestExecutionListener implements TestExecutionListener {
|
||||
|
||||
@@ -164,7 +168,6 @@ public class FailingBeforeAndAfterMethodsTestNGTests {
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@TestExecutionListeners(inheritListeners = false)
|
||||
public static abstract class BaseTestCase extends AbstractTestNGSpringContextTests {
|
||||
|
||||
Reference in New Issue
Block a user