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,23 +108,27 @@ 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();
for (var p : args) { try (var softly = new AutoCloseableSoftAssertions()) {
var found = false; for (var p : args) {
for (var a : params) { var found = false;
if (a.startsWith(p)) { for (var a : params) {
found = true; if (a.startsWith(p)) {
break; found = true;
break;
}
} }
softly.assertThat(found).as(p + " not found.").isTrue();
} }
assertThat(found).as(p + " not found.").isTrue();
} }
var path = EXAMPLES.getAbsolutePath(); var path = EXAMPLES.getAbsolutePath();
@ -157,14 +162,17 @@ class DokkaOperationTest {
assertThat(params).hasSize(matches.size()); assertThat(params).hasSize(matches.size());
IntStream.range(0, params.size()).forEach(i -> { try (var softly = new AutoCloseableSoftAssertions()) {
if (params.get(i).contains(".jar;")) { IntStream.range(0, params.size()).forEach(i -> {
var jars = params.get(i).split(";"); if (params.get(i).contains(".jar;")) {
Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).as(matches.get(i)).contains(jar)); var jars = params.get(i).split(";");
} else { Arrays.stream(jars).forEach(jar ->
assertThat(params.get(i)).as(params.get(i)).isEqualTo(matches.get(i)); softly.assertThat(matches.get(i)).as(matches.get(i)).contains(jar));
} } else {
}); softly.assertThat(params.get(i)).as(params.get(i)).isEqualTo(matches.get(i));
}
});
}
} }
@Test @Test

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,28 +226,32 @@ 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();
for (var p : args) { try (var softly = new AutoCloseableSoftAssertions()) {
var found = false; for (var p : args) {
for (var a : params) { var found = false;
if (a.startsWith(p)) { for (var a : params) {
found = true; if (a.startsWith(p)) {
break; found = true;
break;
}
} }
softly.assertThat(found).as(p + " not found.").isTrue();
} }
assertThat(found).as(p + " not found.").isTrue();
} }
var matches = List.of( var matches = List.of(