diff options
Diffstat (limited to 'vespa-osgi-testrunner/src/test/java/TestDescriptorTest.java')
-rw-r--r-- | vespa-osgi-testrunner/src/test/java/TestDescriptorTest.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/vespa-osgi-testrunner/src/test/java/TestDescriptorTest.java b/vespa-osgi-testrunner/src/test/java/TestDescriptorTest.java new file mode 100644 index 00000000000..9462a52ed9f --- /dev/null +++ b/vespa-osgi-testrunner/src/test/java/TestDescriptorTest.java @@ -0,0 +1,70 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +import com.yahoo.vespa.testrunner.TestDescriptor; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Collections; +import java.util.List; + +/** + * @author mortent + */ +public class TestDescriptorTest { + + @Test + public void parses_system_test_only () { + String testDescriptor = "{\n" + + " \"version\": \"1.0\",\n" + + " \"configuredTests\": {\n" + + " \"systemTests\": [\n" + + " \"ai.vespa.test.SystemTest1\",\n" + + " \"ai.vespa.test.SystemTest2\"\n" + + " ]\n" + + " " + + "}\n" + + "}"; + var testClassDescriptor = TestDescriptor.fromJsonString(testDescriptor); + + var systemTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.systemtest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.SystemTest1", "ai.vespa.test.SystemTest2"), systemTests); + + var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); + Assertions.assertIterableEquals(Collections.emptyList(), stagingTests); + + var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest); + Assertions.assertIterableEquals(Collections.emptyList(), productionTests); + } + + @Test + public void parsesDescriptorFile() { + String testDescriptor = "{\n" + + " \"version\": \"1.0\",\n" + + " \"configuredTests\": {\n" + + " \"systemTests\": [\n" + + " \"ai.vespa.test.SystemTest1\",\n" + + " \"ai.vespa.test.SystemTest2\"\n" + + " ],\n" + + " \"stagingTests\": [\n" + + " \"ai.vespa.test.StagingTest1\",\n" + + " \"ai.vespa.test.StagingTest2\"\n" + + " ],\n" + + " \"productionTests\": [\n" + + " \"ai.vespa.test.ProductionTest1\",\n" + + " \"ai.vespa.test.ProductionTest2\"\n" + + " ]\n" + + " " + + "}\n" + + "}"; + var testClassDescriptor = TestDescriptor.fromJsonString(testDescriptor); + + var systemTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.systemtest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.SystemTest1", "ai.vespa.test.SystemTest2"), systemTests); + + var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.StagingTest1", "ai.vespa.test.StagingTest2"), stagingTests); + + var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest); + Assertions.assertIterableEquals(List.of("ai.vespa.test.ProductionTest1", "ai.vespa.test.ProductionTest2"), productionTests); + } +} |