org.gradle.testing.testng.TestNGLoggingOutputCaptureIntegrationTest.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.testing.testng
import org.gradle.integtests.fixtures.HtmlTestExecutionResult
import org.gradle.integtests.fixtures.JUnitXmlTestExecutionResult
import org.gradle.integtests.fixtures.MultiVersionIntegrationSpec
import org.gradle.integtests.fixtures.TargetCoverage
import org.gradle.testing.fixture.TestNGCoverage
import static org.hamcrest.Matchers.is
@TargetCoverage({TestNGCoverage.STANDARD_COVERAGE})
class TestNGLoggingOutputCaptureIntegrationTest extends MultiVersionIntegrationSpec {
def setup() {
buildFile << """
apply plugin: "java"
repositories { jcenter() }
dependencies { testCompile "org.testng:testng:$version" }
test {
useTestNG()
reports.junitXml.outputPerTestCase = true
onOutput { test, event -> print "\$test -> \$event.message" }
}
"""
file("src/test/java/FooTest.java") << """import org.testng.annotations.*;
public class FooTest {
static { System.out.println("static out"); System.err.println("static err"); }
public FooTest() {
System.out.println("constructor out"); System.err.println("constructor err");
}
@BeforeClass public static void beforeClass() {
System.out.println("beforeClass out"); System.err.println("beforeClass err");
}
@BeforeTest public void beforeTest() {
System.out.println("beforeTest out"); System.err.println("beforeTest err");
}
@Test public void m1() {
System.out.print("m1: ");
System.out.print("\u03b1