Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate support for running Spock Tests #2846

Merged
merged 1 commit into from
Dec 3, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Current
Fixed: GITHUB-2844: Deprecate support for running Spock Tests (Krishnan Mahadevan)
Fixed: GITHUB-893: TestNG should provide an Api which allow to find all dependent of a specific test (Krishnan Mahadevan)
New: Added .yml file extension for yaml suite files, previously only .yaml was allowed for yaml (Steven Jubb)
Fixed: GITHUB-141: regular expression in "dependsOnMethods" does not work (Krishnan Mahadevan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ tasks.withType<JavaCompile>().configureEach {
// But let's not fail builds for that reason
if (JavaVersion.current() != JavaVersion.VERSION_17) {
compilerArgs.add("-Xlint:deprecation")
compilerArgs.add("-Werror")
//If we have deprecation warnings, the build fails
//which should not happen
//compilerArgs.add("-Werror")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.junit.runner.Description;
import org.testng.internal.ConstructorOrMethod;

/** @deprecated - Support for Spock1.x series is being deprecated as of TestNG <code>7.6.2</code> */
@Deprecated
public class JUnit4SpockMethod extends ConstructorOrMethod {

private static final Class<?> SPOCK_SPEC_CLASS = getSpockSpecClass();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.testng.junit;

import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.runner.Description;
import org.testng.ITestObjectFactory;
import org.testng.internal.ConstructorOrMethod;
import org.testng.internal.Utils;
import org.testng.log4testng.Logger;

public class JUnit4TestMethod extends JUnitTestMethod {

private static final AtomicBoolean warnOnce = new AtomicBoolean(false);

public JUnit4TestMethod(
ITestObjectFactory objectFactory, JUnitTestClass owner, Description desc) {
super(objectFactory, owner, desc.getMethodName(), getMethod(owner.getRealClass(), desc), desc);
Expand All @@ -15,6 +19,15 @@ public JUnit4TestMethod(
private static ConstructorOrMethod getMethod(Class<?> c, Description desc) {
String method = desc.getMethodName();
if (JUnit4SpockMethod.isSpockClass(c)) {
if (warnOnce.compareAndSet(false, true)) {
String msg =
"Support for running Spock 1.x series is being deprecated and will "
+ "be removed in the upcoming versions of TestNG. Spock 2.x based tests use "
+ "the JUnit5 engine for running them. "
+ "To run both TestNG and Spock2.x tests using JUnit5 refer to "
+ "https://github.com/junit-team/testng-engine";
Logger.getLogger(JUnit4TestMethod.class).warn(msg);
}
return new JUnit4SpockMethod(desc);
}
if (method == null) {
Expand Down
21 changes: 0 additions & 21 deletions testng-core/src/test/groovy/test/groovy/GroovyTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,6 @@ class GroovyTest extends SimpleBaseTest {
assert adapter.passedTests.size() == 1
}

@Test
void spockSampleShouldWork() {
def tng = create(SpockSample)
tng.setJUnit(true)
def adapter = new TestListenerAdapter()
tng.addListener((ITestNGListener)adapter)
tng.run()

assert adapter.failedTests.isEmpty()
assert adapter.skippedTests.isEmpty()
assert adapter.passedTests.size() == 1
}

@Test
void reporterWithSpockSampleShouldWork() {
def tng = create(SpockSample)
tng.setJUnit(true)
tng.addListener((ITestNGListener) new JUnitXMLReporter())
tng.run()
}

@Test(description = "GITHUB-2360")
void groovyInternalMethodsAreSkipped() {
def tng = create Issue2360Sample
Expand Down
17 changes: 0 additions & 17 deletions testng-core/src/test/groovy/test/groovy/SpockSample.groovy

This file was deleted.

1 change: 0 additions & 1 deletion testng-core/testng-core-build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ dependencies {
testImplementation("org.codehaus.groovy:groovy-all:_") {
exclude("org.testng", "testng")
}
testImplementation("org.spockframework:spock-core:_")
testImplementation("org.apache-extras.beanshell:bsh:_")
testImplementation("org.mockito:mockito-core:_")
testImplementation("org.jboss.shrinkwrap:shrinkwrap-api:_")
Expand Down
32 changes: 1 addition & 31 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@ version.org.assertj..assertj-core=3.22.0
## # available=3.23.0
## # available=3.23.1

## DONOT alter the version of groovy here because we need the compatible
## version with what spock needs
version.org.codehaus.groovy..groovy-all=2.5.4
## # available=3.0.11
## # available=3.0.12
## # available=3.0.13
version.org.codehaus.groovy..groovy-all=3.0.13

version.org.gridkit.jvmtool..heaplib=0.2

Expand All @@ -129,31 +124,6 @@ version.org.ops4j.pax.exam..pax-exam-testng=4.13.5

version.org.ops4j.pax.url..pax-url-aether=2.6.12

## DONOT upgrade the version to the 2.x series because spock 2.x series
## starts expecting adherance the JUnit5 engine and we are NOT
## planning to support running JUnit5 tests in TestNG and so we don't have
## JUnit5 compliant runner
version.org.spockframework..spock-core=1.3-groovy-2.5
## # available=2.1-M1-groovy-2.5
## # available=2.1-M1-groovy-3.0
## # available=2.1-M2-groovy-2.5
## # available=2.1-M2-groovy-3.0
## # available=2.2-groovy-2.5
## # available=2.2-groovy-3.0
## # available=2.2-groovy-4.0
## # available=2.2-M1-groovy-2.5
## # available=2.2-M1-groovy-3.0
## # available=2.2-M1-groovy-4.0
## # available=2.2-M2-groovy-2.5
## # available=2.2-M2-groovy-3.0
## # available=2.2-M2-groovy-4.0
## # available=2.2-M3-groovy-2.5
## # available=2.2-M3-groovy-3.0
## # available=2.2-M3-groovy-4.0
## # available=2.3-groovy-2.5
## # available=2.3-groovy-3.0
## # available=2.3-groovy-4.0

version.org.webjars..jquery=3.6.1

version.org.xmlunit..xmlunit-assertj=2.9.0
Expand Down