@IndicativeSentencesGeneration is the enhancement of the Indicative Sentences Display Name Generator.
It allows the customization of separator and DisplayNameGenerator.
package org.wesome.junit5;
public class AppleCalculator {
public int addApple(int apple1, int apple2) {
int apple = apple1 + apple2;
return apple;
}
}
package org.wesome.junit5;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
import org.junit.jupiter.api.IndicativeSentencesGeneration;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@IndicativeSentencesGeneration(separator = "->", generator = ReplaceUnderscores.class)
class Apple_Calculator_Test {
@Test
void add_Apple() {
AppleCalculator appleCalculator = new AppleCalculator();
assertEquals(2, appleCalculator.addApple(1, 1), "1 apple + 1 apple is 2 apple");
}
@Nested
class Apple_Calculator_Nested_Test {
@Test
void add_Apple() {
AppleCalculator appleCalculator = new AppleCalculator();
assertEquals(4, appleCalculator.addApple(2, 2), "2 apple + 2 apple is 4 apple");
}
}
}
plugins {
id 'java'
}
group 'org.wesome'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
}
test {
useJUnitPlatform()
}