<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">

    <test-code>
        <description>JUnit4 Test class contains setUp</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>3</expected-linenumbers>
        <code><![CDATA[
import org.junit.Test;
public class Foo {
    public void setUp() {
    }
    @Test
    public void foo() {
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit4 Test class with Before is ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.Before;
import org.junit.Test;
public class Foo {
    @Before
    public void setUp() {
    }
    @Test
    public void foo() {
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit4 Test class with renamed setup using Before is ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.Before;
import org.junit.Test;
public class Foo {
    @Before
    public void configure() {
    }
    @Test
    public void foo() {
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#1400 False positive with JUnit4TestShouldUseBeforeAnnotation</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.Before;
import org.junit.Test;
import my.EsSetup;
public class Foo {
    EsSetup esSetup;
    @Before("@ResetEsSetup")
    public void setUp() {
        esSetup.execute(EsSetup.deleteAll());
    }
    @Test
    public void someTest() {}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>Contains setUp, not a JUnit 4/5/TestNG test</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void setUp() {}
    public void foo() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>JUnit4 Test class contains setUp with different signature is ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.Test;

public class Foo {
    public void setUp(int something) {}

    @Test
    public void foo() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>[java] JUnit4TestShouldUseBeforeAnnotation false positive when overriding setUp #1592</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import net.sourceforge.pmd.lang.java.rule.bestpractices.UnitTestShouldUseBeforeAnnotationTest.BaseTest;

public class AReallyCoolFeatureTest extends BaseTest {
    @Override
    public void setUp() {
        super.setUp();
    }

    @Override
    public void tearDown() {
        super.tearDown();
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>TestNG class contains setUp</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>4</expected-linenumbers>
        <code><![CDATA[
import org.testng.annotations.Test;

public class MyTestCase {
    public void setUp() {} // violation expected here

    @Test
    public void myTest() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>TestNG class contains setUp with different signature is ok (#1446)</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.testng.annotations.Test;
import java.lang.reflect.Method;

public class Foo {
    public void setUp(Method m) {}

    @Test
    public void foo() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>TestNG with @BeforeMethod is ok (#1446)</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class MyTestCase {
    @BeforeMethod
    public void setUp() {}

    @Test
    public void myTest() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>TestNG with @BeforeClass is ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class MyTestCase {
    @BeforeClass
    public void setUp() {}

    @Test
    public void myTest() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>JUnit5 Test class contains setUp</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>4</expected-linenumbers>
        <code><![CDATA[
import org.junit.jupiter.api.Test;

public class MyTestCase {
    public void setUp() {} // violation expected

    @Test
    public void myTest() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>JUnit5 Test class with BeforeEach is ok (#940)</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class MyTestCase {
    @BeforeEach
    public void setUp() {}

    @Test
    public void myTest() {}
}
]]></code>
    </test-code>

    <test-code>
        <description>JUnit5 Test class with BeforeAll is ok (#940)</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class MyTestCase {
    @BeforeAll
    public void setUp() {}

    @Test
    public void myTest() {}
}
]]></code>
    </test-code>
</test-data>
