-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run Smithy test suites as parameterized tests
This commit updates SmithyTestSuite to support easily running test suites as JUnit 5 ParameterizedTests. This allows JUnit to control how tests are executed and provides better error reporting. Tests seem to execute more or less in the same amount of time as before.
- Loading branch information
Showing
26 changed files
with
224 additions
and
109 deletions.
There are no files selected for viewing
23 changes: 12 additions & 11 deletions
23
smithy-aws-traits/src/test/java/software/amazon/smithy/aws/traits/TestRunnerTest.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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
package software.amazon.smithy.aws.traits; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.model.loader.ModelAssembler; | ||
import java.util.concurrent.Callable; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import software.amazon.smithy.model.validation.testrunner.SmithyTestCase; | ||
import software.amazon.smithy.model.validation.testrunner.SmithyTestSuite; | ||
|
||
public class TestRunnerTest { | ||
@Test | ||
public void testRunner() { | ||
ModelAssembler assembler = Model.assembler(getClass().getClassLoader()) | ||
.discoverModels(getClass().getClassLoader()); | ||
@ParameterizedTest(name = "{0}") | ||
@MethodSource("source") | ||
public void testRunner(String filename, Callable<SmithyTestCase.Result> callable) throws Exception { | ||
callable.call(); | ||
} | ||
|
||
System.out.println(SmithyTestSuite.runner() | ||
.setModelAssemblerFactory(assembler::copy) | ||
.addTestCasesFromUrl(TestRunnerTest.class.getResource("errorfiles")) | ||
.run()); | ||
public static Stream<?> source() { | ||
return SmithyTestSuite.defaultParameterizedTestSource(TestRunnerTest.class); | ||
} | ||
} |
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
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
Oops, something went wrong.