Skip to content

Commit

Permalink
Added soft assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Oct 27, 2024
1 parent 41e5467 commit 6cb78a9
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/test/java/rife/bld/extension/GeneratedVersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package rife.bld.extension;

import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import rife.bld.BaseProject;
Expand Down Expand Up @@ -116,9 +117,11 @@ void testBuildTemplate() {
var t = gv.buildTemplate();
assertThat(t).isNotNull();

assertThat(gv.getProject()).isEqualTo(PROJECT);
assertThat(gv.getPackageName()).isEqualTo(PROJECT.pkg());
assertThat(gv.getProjectName()).isEqualTo(PROJECT.name());
try (var softly = new AutoCloseableSoftAssertions()) {
softly.assertThat(gv.getProject()).isEqualTo(PROJECT);
softly.assertThat(gv.getPackageName()).isEqualTo(PROJECT.pkg());
softly.assertThat(gv.getProjectName()).isEqualTo(PROJECT.name());
}

assertThat(t.getContent()).contains("package com.example;").contains("class GeneratedVersion")
.contains("PROJECT = \"MyExample\";").contains("MAJOR = 2").contains("MINOR = 1")
Expand Down Expand Up @@ -201,13 +204,15 @@ void testGeneratedVersion() {
gv.setDirectory(new File("build"));
gv.setExtension(".java");

assertThat(gv.getProject()).as("project").isEqualTo(PROJECT);
assertThat(gv.getTemplate()).as("template").exists();
assertThat(gv.getPackageName()).as("package name").isEqualTo("com.example.cool");
assertThat(gv.getProjectName()).as("project name").isEqualTo("Cool App");
assertThat(gv.getClassName()).as("class name").isEqualTo("CoolVersion");
assertThat(gv.getExtension()).as("extension").isEqualTo(".java");
assertThat(gv.getDirectory()).as("directory").isDirectory();
try (var softly = new AutoCloseableSoftAssertions()) {
softly.assertThat(gv.getProject()).as("project").isEqualTo(PROJECT);
softly.assertThat(gv.getTemplate()).as("template").exists();
softly.assertThat(gv.getPackageName()).as("package name").isEqualTo("com.example.cool");
softly.assertThat(gv.getProjectName()).as("project name").isEqualTo("Cool App");
softly.assertThat(gv.getClassName()).as("class name").isEqualTo("CoolVersion");
softly.assertThat(gv.getExtension()).as("extension").isEqualTo(".java");
softly.assertThat(gv.getDirectory()).as("directory").isDirectory();
}
}

@Test
Expand Down

0 comments on commit 6cb78a9

Please sign in to comment.