Search in sources :

Example 51 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class FailingSimpleTestCases method testedAPI_noTestedAPI.

@Test
public void testedAPI_noTestedAPI() {
    @TestGroup
    class MyTest {

        @TestCase
        @TestedStatement("a statement")
        public void testCase() {
            Assert.fail();
        }
    }
    TestResult s = TU.runTestGroup(new MyTest(), TU.EMPTY_ARGV);
    Assert.assertTrue(!s.isOK());
    Assert.assertEquals("test cases: 1; all failed", s.getMessage());
}
Also used : TestGroup(com.sun.tck.test.TestGroup) TestResult(com.oracle.tck.lib.autd2.TestResult) Test(org.junit.Test)

Example 52 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method test_04_IteratorOfIntegers_2.

@Test
public void test_04_IteratorOfIntegers_2() {
    @TestGroup
    class Test {

        Iterator<Integer> component = IntStream.range(55, 98).iterator();

        int counter;

        @TestCase
        public void test(@TestData("component") int r) {
            counter++;
        }
    }
    Test tg = new Test();
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(tg);
    Assert.assertTrue(s.isOK());
    Assert.assertEquals(43, tg.counter);
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Test(org.junit.Test) Iterator(java.util.Iterator) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestGroup(com.sun.tck.test.TestGroup) Test(org.junit.Test)

Example 53 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method test_04_IteratorOfObjectArrays_01.

@Test
public void test_04_IteratorOfObjectArrays_01() {
    @TestGroup
    class Test {

        Iterator<Object[]> component = Arrays.asList(new Object[] { 1, "1" }, new Object[] { 2, "3" }, new Object[] { 6, "4" }, new Object[] { 5, "5" }).iterator();

        int counter = 0;

        @TestCase
        @TestData("component")
        public void test(int x, String s) {
            counter++;
        }
    }
    Test tg = new Test();
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(tg);
    Assert.assertTrue(s.isOK());
    Assert.assertEquals(4, tg.counter);
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : Test(org.junit.Test) Iterator(java.util.Iterator) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestGroup(com.sun.tck.test.TestGroup) Test(org.junit.Test)

Example 54 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class IteratorAsSupportedDataContainer method test_04_IteratorOfIntegers_01.

@Test
public void test_04_IteratorOfIntegers_01() {
    @TestGroup
    class Test {

        Iterator<Integer> component = Arrays.asList(1, 2, 3, 4, 5).iterator();

        int counter = 0;

        @TestCase
        public void test(@TestData("component") int x) {
            counter++;
        }
    }
    Test tg = new Test();
    com.oracle.tck.lib.autd2.TestResult s = TU.runTestGroup(tg);
    Assert.assertTrue(s.isOK());
    Assert.assertEquals(5, tg.counter);
    Assert.assertEquals("test cases: 1; all passed", s.getMessage());
}
Also used : TestData(com.sun.tck.lib.tgf.TestData) Test(org.junit.Test) Iterator(java.util.Iterator) BaseTestGroup(com.oracle.tck.lib.autd2.unittests.BaseTestGroup) TestGroup(com.sun.tck.test.TestGroup) Test(org.junit.Test)

Example 55 with TestGroup

use of com.sun.tck.test.TestGroup in project jtharness by openjdk.

the class BigDecimalTestSample method test.

@org.junit.Test
public void test() {
    @TestGroup
    class MyBigDecimalTest {

        Values setup_1() {
            return DataFactory.createColumn(valueOf(0), valueOf(3)).multiply(valueOf(63), valueOf(17));
        }

        Values setup_2() {
            return DataFactory.createColumn(valueOf(1), valueOf(4)).multiply(valueOf(33), valueOf(7));
        }

        Values setup_3() {
            return setup_1().unite(setup_2());
        }

        @TestCase
        @TestData("setup_3")
        public void testMultiply(BigDecimal instance, BigDecimal anotherInstance) {
            long expectedResult = instance.longValue() * anotherInstance.longValue();
            BigDecimal result = instance.multiply(anotherInstance);
            Assert.assertEquals(expectedResult, result.longValue());
        }

        @TestCase
        @TestData("setup_2")
        public void testAdd(BigDecimal instance, BigDecimal anotherInstance) {
            long expectedResult = instance.longValue() + anotherInstance.longValue();
            BigDecimal result = instance.add(anotherInstance);
            Assert.assertEquals(expectedResult, result.longValue());
        }
    }
    final MyBigDecimalTest test = new MyBigDecimalTest();
    com.oracle.tck.lib.autd2.TestResult status = com.oracle.tck.lib.autd2.unittests.TU.runTestGroup(test, TU.EMPTY_ARGV);
    assertTrue(status.isOK());
    System.out.println(status);
}
Also used : TestGroup(com.sun.tck.test.TestGroup) BigDecimal(java.math.BigDecimal)

Aggregations

TestGroup (com.sun.tck.test.TestGroup)55 Test (org.junit.Test)53 TestResult (com.oracle.tck.lib.autd2.TestResult)49 Values (com.sun.tck.lib.tgf.Values)27 TestedAPI (com.sun.tck.test.TestedAPI)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 TestData (com.sun.tck.lib.tgf.TestData)7 Color (java.awt.Color)7 BaseTestGroup (com.oracle.tck.lib.autd2.unittests.BaseTestGroup)4 DataFactory (com.sun.tck.lib.tgf.DataFactory)4 Longs (com.sun.tck.lib.tgf.data.Longs)3 ColorSpace (java.awt.color.ColorSpace)3 Iterator (java.util.Iterator)3 List (java.util.List)3 RandomAccess (java.util.RandomAccess)3 Collectors.toList (java.util.stream.Collectors.toList)3 Assert.assertEquals (com.sun.tck.lib.Assert.assertEquals)2 Assert.assertTrue (com.sun.tck.lib.Assert.assertTrue)2 ExpectedExceptions (com.sun.tck.lib.ExpectedExceptions)2 DataFactory.createColumn (com.sun.tck.lib.tgf.DataFactory.createColumn)2