Skip to content

Commit

Permalink
Pass testSourceUri to dynamicTest and to dynamicContainer for conveni…
Browse files Browse the repository at this point in the history
…ent navigation to tests data in IntelliJ

Signed-off-by: Ivan Kochurkin <[email protected]>
  • Loading branch information
KvanTTT committed Jun 20, 2022
1 parent a95d268 commit a2c8d68
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -95,18 +96,21 @@ public List<DynamicNode> runtimeTests() {
for (String group : testDescriptors.keySet()) {
ArrayList<DynamicNode> descriptorTests = new ArrayList<>();
RuntimeTestDescriptor[] descriptors = testDescriptors.get(group);
Path descriptorGroupPath = Paths.get(RuntimeTestUtils.resourcePath.toString(), "descriptors", group);
for (RuntimeTestDescriptor descriptor : descriptors) {
descriptorTests.add(dynamicTest(descriptor.name, () -> {
Path descriptorTestPath = Paths.get(descriptorGroupPath.toString(), descriptor.name + ".txt");
descriptorTests.add(dynamicTest(descriptor.name, descriptorTestPath.toUri(), () -> {
try (RuntimeRunner runner = createRuntimeRunner()) {
String errorMessage = test(descriptor, runner);
if (errorMessage != null) {
runner.setSaveTestDir(true);
fail(descriptor.name + "; " + errorMessage + "\nDirectory: " + runner.getTempDirPath());
fail(descriptor.name + "; " + errorMessage + "\nTest directory: " + runner.getTempDirPath());
}
}
}));
}
result.add(dynamicContainer(group, descriptorTests));

result.add(dynamicContainer(group, descriptorGroupPath.toUri(), Arrays.stream(descriptorTests.toArray(new DynamicNode[0]))));
}

return result;
Expand Down

0 comments on commit a2c8d68

Please sign in to comment.