From 4ae9cf7cf11af1626cb5dd127c020c98507f8e7f Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 10 Jan 2013 16:42:44 +0100 Subject: [PATCH] Ensure JUnit & TestNG tests run in spring-test Prior to this commit, the Gradle build configuration only executed TestNG-based tests and effectively disabled all JUnit-based tests in the spring-test module. Furthermore, TestNG-based tests were not properly reported in Bamboo CI builds. This commit ensures that both JUnit and TestNG tests are executed in the Gradle build by defining a new testNG task within the spring-test configuration. The test task now depends on the new testNG task. Furthermore, the testNG task makes use of Gradle 1.3's support for generating test reports for TestNG tests alongside reports for JUnit tests. The net effect is that all tests are executed and reportedly properly in Bamboo builds on the CI server. - Enabled both JUnit and TestNG tests for the spring-test module. - Corrected bugs in FailingBeforeAndAfterMethodsTests introduced in commit 3d1b3868fe3b38f5552883f54111c53f6ee75572. - Deleted the now obsolete SPR-9398.txt file. Issue: SPR-9398 --- build.gradle | 14 +++++++++++++- .../testng/FailingBeforeAndAfterMethodsTests.java | 8 +++----- .../test/context/testng/SPR-9398.txt | 3 --- 3 files changed, 16 insertions(+), 9 deletions(-) delete mode 100644 spring-test/src/test/java/org/springframework/test/context/testng/SPR-9398.txt diff --git a/build.gradle b/build.gradle index 724927507fb..3ddef1b2398 100644 --- a/build.gradle +++ b/build.gradle @@ -640,10 +640,22 @@ project("spring-webmvc-portlet") { project("spring-test") { description = "Spring TestContext Framework" + + task testNG(type: Test) { + useTestNG() + // "TestCase" classes are run by other test classes, not the build. + exclude "**/*TestCase.class" + // Generate TestNG reports alongside JUnit reports. + testReport true + } + test { + dependsOn testNG useJUnit() - useTestNG() + // "TestCase" classes are run by other test classes, not the build. + exclude "**/*TestCase.class" } + dependencies { compile(project(":spring-core")) optional(project(":spring-beans")) diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java index 05ba435f9b3..74e8f2513ad 100644 --- a/spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/testng/FailingBeforeAndAfterMethodsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -237,8 +237,7 @@ public class FailingBeforeAndAfterMethodsTests { @BeforeTransaction public void beforeTransaction() { - // See SPR-8116 - //org.testng.Assert.fail("always failing beforeTransaction()"); + org.testng.Assert.fail("always failing beforeTransaction()"); } } @@ -251,8 +250,7 @@ public class FailingBeforeAndAfterMethodsTests { @AfterTransaction public void afterTransaction() { - // See SPR-8116 - //org.testng.Assert.fail("always failing afterTransaction()"); + org.testng.Assert.fail("always failing afterTransaction()"); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/SPR-9398.txt b/spring-test/src/test/java/org/springframework/test/context/testng/SPR-9398.txt deleted file mode 100644 index dfbdc9ad831..00000000000 --- a/spring-test/src/test/java/org/springframework/test/context/testng/SPR-9398.txt +++ /dev/null @@ -1,3 +0,0 @@ -TODO [SPR-9398] re-enable TestNG support for spring-test. - -These TestNG test classes are currently not run at all.