Added soft assertions

This commit is contained in:
Erik C. Thauvin 2024-10-27 16:17:34 -07:00
parent 0983f323a2
commit d797c515bb
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 51 additions and 38 deletions

View file

@ -16,6 +16,7 @@
package rife.bld.extension; package rife.bld.extension;
import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import rife.bld.blueprints.BaseProjectBlueprint; import rife.bld.blueprints.BaseProjectBlueprint;
@ -107,14 +108,17 @@ class DokkaOperationTest {
))) )))
.suppressInheritedMembers(true); .suppressInheritedMembers(true);
assertThat(op.globalLinks()).as("globalLinks").hasSize(2); try (var softly = new AutoCloseableSoftAssertions()) {
assertThat(op.globalPackageOptions()).as("globalPackageOptions").hasSize(4); softly.assertThat(op.globalLinks()).as("globalLinks").hasSize(2);
assertThat(op.globalSrcLink()).as("globalSrcLink").hasSize(4); softly.assertThat(op.globalPackageOptions()).as("globalPackageOptions").hasSize(4);
assertThat(op.includes()).as("includes").hasSize(4); softly.assertThat(op.globalSrcLink()).as("globalSrcLink").hasSize(4);
assertThat(op.pluginConfigurations()).as("pluginConfigurations").hasSize(3); softly.assertThat(op.includes()).as("includes").hasSize(4);
assertThat(op.pluginsClasspath()).as("pluginsClasspath").hasSize(9); softly.assertThat(op.pluginConfigurations()).as("pluginConfigurations").hasSize(3);
softly.assertThat(op.pluginsClasspath()).as("pluginsClasspath").hasSize(9);
}
var params = op.executeConstructProcessCommandList(); var params = op.executeConstructProcessCommandList();
try (var softly = new AutoCloseableSoftAssertions()) {
for (var p : args) { for (var p : args) {
var found = false; var found = false;
for (var a : params) { for (var a : params) {
@ -123,7 +127,8 @@ class DokkaOperationTest {
break; break;
} }
} }
assertThat(found).as(p + " not found.").isTrue(); softly.assertThat(found).as(p + " not found.").isTrue();
}
} }
var path = EXAMPLES.getAbsolutePath(); var path = EXAMPLES.getAbsolutePath();
@ -157,15 +162,18 @@ class DokkaOperationTest {
assertThat(params).hasSize(matches.size()); assertThat(params).hasSize(matches.size());
try (var softly = new AutoCloseableSoftAssertions()) {
IntStream.range(0, params.size()).forEach(i -> { IntStream.range(0, params.size()).forEach(i -> {
if (params.get(i).contains(".jar;")) { if (params.get(i).contains(".jar;")) {
var jars = params.get(i).split(";"); var jars = params.get(i).split(";");
Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).as(matches.get(i)).contains(jar)); Arrays.stream(jars).forEach(jar ->
softly.assertThat(matches.get(i)).as(matches.get(i)).contains(jar));
} else { } else {
assertThat(params.get(i)).as(params.get(i)).isEqualTo(matches.get(i)); softly.assertThat(params.get(i)).as(params.get(i)).isEqualTo(matches.get(i));
} }
}); });
} }
}
@Test @Test
void executeNoProjectTest() { void executeNoProjectTest() {

View file

@ -16,6 +16,7 @@
package rife.bld.extension.dokka; package rife.bld.extension.dokka;
import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.File;
@ -225,19 +226,22 @@ class SourceSetTest {
.srcLink(Path.of(PATH_3), "remote3", "#suffix3") .srcLink(Path.of(PATH_3), "remote3", "#suffix3")
.suppressedFiles(SUP_1, SUP_2); .suppressedFiles(SUP_1, SUP_2);
assertThat(sourceSet.classpath()).as("classpath").hasSize(2); try (var softly = new AutoCloseableSoftAssertions()) {
assertThat(sourceSet.dependentSourceSets()).as("dependentSourceSets").hasSize(2); softly.assertThat(sourceSet.classpath()).as("classpath").hasSize(2);
assertThat(sourceSet.documentedVisibilities()).as("documentedVisibilities").hasSize(2); softly.assertThat(sourceSet.dependentSourceSets()).as("dependentSourceSets").hasSize(2);
assertThat(sourceSet.externalDocumentationLinks()).as("externalDocumentationLinks").hasSize(2); softly.assertThat(sourceSet.documentedVisibilities()).as("documentedVisibilities").hasSize(2);
assertThat(sourceSet.includes()).as("includes").hasSize(4); softly.assertThat(sourceSet.externalDocumentationLinks()).as("externalDocumentationLinks").hasSize(2);
assertThat(sourceSet.perPackageOptions()).as("perPackageOptions").hasSize(2); softly.assertThat(sourceSet.includes()).as("includes").hasSize(4);
assertThat(sourceSet.samples()).as("samples").hasSize(2); softly.assertThat(sourceSet.perPackageOptions()).as("perPackageOptions").hasSize(2);
assertThat(sourceSet.src()).as("src").hasSize(4); softly.assertThat(sourceSet.samples()).as("samples").hasSize(2);
assertThat(sourceSet.srcLinks()).as("srcLinks").hasSize(3); softly.assertThat(sourceSet.src()).as("src").hasSize(4);
assertThat(sourceSet.suppressedFiles()).as("suppressedFiles").hasSize(2); softly.assertThat(sourceSet.srcLinks()).as("srcLinks").hasSize(3);
softly.assertThat(sourceSet.suppressedFiles()).as("suppressedFiles").hasSize(2);
}
var params = sourceSet.args(); var params = sourceSet.args();
try (var softly = new AutoCloseableSoftAssertions()) {
for (var p : args) { for (var p : args) {
var found = false; var found = false;
for (var a : params) { for (var a : params) {
@ -246,7 +250,8 @@ class SourceSetTest {
break; break;
} }
} }
assertThat(found).as(p + " not found.").isTrue(); softly.assertThat(found).as(p + " not found.").isTrue();
}
} }
var matches = List.of( var matches = List.of(