-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issues/163: Support for JUnit 5s @nested test classes
issues/163: Support for JUnit 5s @nested test classes
- Loading branch information
Showing
10 changed files
with
264 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
skippy-core/src/test/java/io/skippy/core/TestImpactAnalysisPredictNestedTestsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/* | ||
* Copyright 2023-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.skippy.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.skippy.core.Prediction.EXECUTE; | ||
import static io.skippy.core.Prediction.SKIP; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TestImpactAnalysisPredictNestedTestsTest { | ||
|
||
@Test | ||
void testPredictNoChange() { | ||
var testImpactAnalysis = TestImpactAnalysis.parse(""" | ||
{ | ||
"id": "F87679D196B903DFE24335295E13DEED", | ||
"classes": { | ||
"0": { | ||
"name": "com.example.ClassA", | ||
"path": "io/skippy/core/nested/ClassA.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "3041DC84" | ||
}, | ||
"1": { | ||
"name": "com.example.ClassB", | ||
"path": "io/skippy/core/nested/ClassB.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "37FA6DE7" | ||
}, | ||
"2": { | ||
"name": "com.example.ClassC", | ||
"path": "io/skippy/core/nested/ClassC.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "B17DF734" | ||
}, | ||
"3": { | ||
"name": "com.example.ClassD", | ||
"path": "io/skippy/core/nested/ClassD.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "41C10CEE" | ||
}, | ||
"4": { | ||
"name": "com.example.NestedTestsTest", | ||
"path": "io/skippy/core/nested/NestedTestsTest.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "C3A3737F" | ||
}, | ||
"5": { | ||
"name": "com.example.NestedTestsTest$Level2BarTest", | ||
"path": "io/skippy/core/nested/NestedTestsTest$Level2BarTest.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "5780C183" | ||
}, | ||
"6": { | ||
"name": "com.example.NestedTestsTest$Level2FooTest", | ||
"path": "io/skippy/core/nested/NestedTestsTest$Level2FooTest.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "3E35762B" | ||
}, | ||
"7": { | ||
"name": "com.example.NestedTestsTest$Level2FooTest$Level3Test", | ||
"path": "io/skippy/core/nested/NestedTestsTest$Level2FooTest$Level3Test.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "FA83D453" | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"class": 4, | ||
"result": "PASSED", | ||
"coveredClasses": [0,1,2,3,4,5,6,7] | ||
}, | ||
{ | ||
"class": 5, | ||
"result": "PASSED", | ||
"coveredClasses": [3,4,5] | ||
}, | ||
{ | ||
"class": 6, | ||
"result": "PASSED", | ||
"coveredClasses": [1,2,4,6,7] | ||
}, | ||
{ | ||
"class": 7, | ||
"result": "PASSED", | ||
"coveredClasses": [2,4,6,7] | ||
} | ||
] | ||
} | ||
"""); | ||
assertEquals(SKIP, testImpactAnalysis.predict("com.example.NestedTestsTest", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
assertEquals(SKIP, testImpactAnalysis.predict("com.example.NestedTestsTest$Level2BarTest", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
assertEquals(SKIP, testImpactAnalysis.predict("com.example.NestedTestsTest$Level2FooTest", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
assertEquals(SKIP, testImpactAnalysis.predict("com.example.NestedTestsTest$Level2FooTest$Level3Test", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
} | ||
|
||
@Test | ||
void testPredictChangeInClassCoveredByNestedTest() { | ||
var testImpactAnalysis = TestImpactAnalysis.parse(""" | ||
{ | ||
"id": "F87679D196B903DFE24335295E13DEED", | ||
"classes": { | ||
"0": { | ||
"name": "com.example.ClassA", | ||
"path": "io/skippy/core/nested/ClassA.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "3041DC84" | ||
}, | ||
"1": { | ||
"name": "com.example.ClassB", | ||
"path": "io/skippy/core/nested/ClassB.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "37FA6DE7" | ||
}, | ||
"2": { | ||
"name": "com.example.ClassC", | ||
"path": "io/skippy/core/nested/ClassC.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "00000000" | ||
}, | ||
"3": { | ||
"name": "com.example.ClassD", | ||
"path": "io/skippy/core/nested/ClassD.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "41C10CEE" | ||
}, | ||
"4": { | ||
"name": "com.example.NestedTestsTest", | ||
"path": "io/skippy/core/nested/NestedTestsTest.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "C3A3737F" | ||
}, | ||
"5": { | ||
"name": "com.example.NestedTestsTest$Level2BarTest", | ||
"path": "io/skippy/core/nested/NestedTestsTest$Level2BarTest.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "5780C183" | ||
}, | ||
"6": { | ||
"name": "com.example.NestedTestsTest$Level2FooTest", | ||
"path": "io/skippy/core/nested/NestedTestsTest$Level2FooTest.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "3E35762B" | ||
}, | ||
"7": { | ||
"name": "com.example.NestedTestsTest$Level2FooTest$Level3Test", | ||
"path": "io/skippy/core/nested/NestedTestsTest$Level2FooTest$Level3Test.class", | ||
"outputFolder": "src/test/resources", | ||
"hash": "FA83D453" | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"class": 4, | ||
"result": "PASSED", | ||
"coveredClasses": [0,1,2,3,4,5,6,7] | ||
}, | ||
{ | ||
"class": 5, | ||
"result": "PASSED", | ||
"coveredClasses": [3,4,5] | ||
}, | ||
{ | ||
"class": 6, | ||
"result": "PASSED", | ||
"coveredClasses": [1,2,4,6,7] | ||
}, | ||
{ | ||
"class": 7, | ||
"result": "PASSED", | ||
"coveredClasses": [2,4,6,7] | ||
} | ||
] | ||
} | ||
"""); | ||
assertEquals(EXECUTE, testImpactAnalysis.predict("com.example.NestedTestsTest", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
assertEquals(SKIP, testImpactAnalysis.predict("com.example.NestedTestsTest$Level2BarTest", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
assertEquals(EXECUTE, testImpactAnalysis.predict("com.example.NestedTestsTest$Level2FooTest", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
assertEquals(EXECUTE, testImpactAnalysis.predict("com.example.NestedTestsTest$Level2FooTest$Level3Test", SkippyConfiguration.DEFAULT, SkippyRepository.getInstance(SkippyConfiguration.DEFAULT)).prediction()); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+945 Bytes
skippy-core/src/test/resources/io/skippy/core/nested/NestedTestsTest$Level2BarTest.class
Binary file not shown.
Binary file added
BIN
+1.04 KB
...e/src/test/resources/io/skippy/core/nested/NestedTestsTest$Level2FooTest$Level3Test.class
Binary file not shown.
Binary file added
BIN
+1 KB
skippy-core/src/test/resources/io/skippy/core/nested/NestedTestsTest$Level2FooTest.class
Binary file not shown.
Binary file added
BIN
+987 Bytes
skippy-core/src/test/resources/io/skippy/core/nested/NestedTestsTest.class
Binary file not shown.