summaryrefslogtreecommitdiffstats
path: root/vespa-osgi-testrunner/src/test/java/TestDescriptorTest.java
blob: 9462a52ed9f3e5c8e099c1b904e1ddae2586e4f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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);
    }
}