<?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>JUnit 3 Test contains no assert</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import junit.framework.TestCase;
public class MyTestCase extends TestCase {
    //negative on rule
    public void testMyCaseWithNoAssert() {
        boolean myVar = false;
        //no assert here
    }
}
        ]]></code>
    </test-code>

   <test-code>
        <description>JUnit 4 Test contains no assert</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import junit.framework.TestCase;
public class MyTestCase extends TestCase {
    //negative on rule
    @org.junit.Test
    public void myCaseWithNoAssert() {
        boolean myVar = false;
        //no assert here
    }
}
        ]]></code>
    </test-code>

   <test-code>
        <description>JUnit 3 Test contains one assert</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import junit.framework.TestCase;
public class MyTestCase extends TestCase {
    //negative on rule
    public void testMyCaseWithOneAssert() {
        boolean myVar = false;
        assertFalse("should be false",myVar);
    }
}
        ]]></code>
    </test-code>

   <test-code>
        <description>JUnit 4 Test contains one assert</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.Test;
public class MyTestCase {
    //negative on rule
    @Test
    public void myCaseWithOneAssert() {
        boolean myVar = false;
        assertFalse("should be false",myVar);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit 3 Test contains more than one assert</description>
        <expected-problems>1</expected-problems>
        <expected-messages>
            <message>Unit tests should not contain more than 1 assert(s).</message>
        </expected-messages>
        <code><![CDATA[
import junit.framework.TestCase;
public class MyTestCase extends TestCase {
    //positive on rule
    public void testMyCaseWithMoreAsserts() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }
}
        ]]></code>
    </test-code>

   <test-code>
        <description>JUnit 4 Test contains more than one assert</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
import org.junit.Test;
public class MyTestCase {
    //positive on rule
    @Test
    public void myCaseWithMoreAsserts() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }
}
        ]]></code>
    </test-code>

   <test-code>
        <description>JUnit 3 Test contains more than one assert, but allowed</description>
        <rule-property name="maximumAsserts">2</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import junit.framework.TestCase;
public class MyTestCase extends TestCase {
    //positive on rule
    public void testMyCaseWithMoreAsserts() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit 4 Test contains more than one assert, but allowed</description>
        <rule-property name="maximumAsserts">2</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.junit.Test;
public class MyTestCase {
    //positive on rule
    @Test
    public void myCaseWithMoreAsserts() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>JUnit 5 Test contains more than one assert</description>
        <expected-problems>5</expected-problems>
        <expected-linenumbers>11,18,25,32,40</expected-linenumbers>
        <code><![CDATA[
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static org.junit.jupiter.api.Assertions.*;

public class MyTestCase {
    @Test
    public void testRegular() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }

    @RepeatedTest(2)
    public void testRepeated() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }

    @TestFactory
    public void testFactory() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }

    @TestTemplate
    public void testTemplate() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }

    @ParameterizedTest
    @ValueSource(strings = {"Hello", "World"})
    public void testParameterized(String value) {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>TestNG Test contains more than one assert</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>5</expected-linenumbers>
        <code><![CDATA[
import org.testng.annotations.Test;

public class MyTestCase {
    @Test
    public void testRegular() {
        boolean myVar = false;
        assertFalse("myVar should be false",myVar);
        assertEquals("should equals false", false, myVar);
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>Should not count unrelated asserts</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
import org.testng.annotations.Test;

public class MyTestCase {
    @Test
    public void testRegular() {
        assertFalse("myVar should be false",false);
    }
    @Test
    public void testRegular2() {
        assertFalse("myVar should be false",false);
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1212 [java] Don't raise JUnitTestContainsTooManyAsserts on JUnit 5's assertAll</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
            package unknown;
            import static org.junit.jupiter.api.Assertions.*;
            import org.junit.jupiter.api.Test;
            import my.MutableInteger;
            import my.SomeClass;

            public class SomeClassTest {

                @Test
                public void testSomeMethod() {
                    MutableInteger mutableInteger = new MutableInteger(2);
                    SomeClass instance = new SomeClass();
                    int expResult = -1;
                    int result = instance.someMethod(mutableInteger);
                    assertAll(() -> assertEquals(expResult, result),
                              () -> assertEquals(3, mutableInteger.getValue()));
                }
            }
            ]]></code>
    </test-code>
    <test-code>
        <description>#2374 [java] False positive JUnitTestContainsTooManyAsserts for JUnit 5 assertAll()</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
            package unknown;
            import static org.junit.jupiter.api.Assertions.*;
            import org.junit.jupiter.api.Test;
            import my.Point;
            import java.util.List;

            class SampleTest {
                @Test
                void sampleTestCase(List<Point> ps) {
                    final Point input = new Point(1, 2);
                    final Point result = ps.add(input);
                    assertAll(
                            () -> assertEquals(2, result.x),
                            () -> assertEquals(4, result.y)
                    );
                }
            }
            ]]></code>
    </test-code>

    <test-code>
        <description>Extra properties</description>
        <rule-property name="extraAssertMethodNames">customAssertion</rule-property>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
            import org.junit.jupiter.api.Test;
            public class A {
                @Test
                void test() {
                    customAssertion("aueoau");
                    customAssertion("aueoau");
                    customAssertion("aueoau");
                }
            }
            ]]></code>
    </test-code>


</test-data>
