mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 18:26:12 +02:00
Start using JUnit 5 (#488)
* Start using JUnit 5 This converts a single test class over to JUnit 5 (YamlUtilsTest). The main differences you'll notice are that @RunWith isn't needed anymore, test classes and test methods can now be package-private, and the @Test annotation comes from the org.junit.jupiter.api package instead of org.junit. There's a lot more differences between 4 and 5 than this that we'll need to keep in mind when converting more test classes; for some more details, see: https://www.baeldung.com/junit-5-migration In order to allow JUnit 4 and 5 test classes to coexist, I've had to add two new dependencies, org.junit.jupiter:junit-jupiter-engine and org.junit.vintage:junit-vintage-engine, which exist in addition to junit:junit for now. Eventually, once we've completed migrating over all JUnit 4 test classes, then we can remove junit and junit-vintage-engine and just be left with junit-jupiter-engine. * Delete no longer needed lockfiles * Merge branch 'master' into first-junit5
This commit is contained in:
parent
eb4bbaf104
commit
3139a2ffee
135 changed files with 1202 additions and 1033 deletions
|
@ -18,23 +18,20 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static google.registry.util.YamlUtils.mergeYaml;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link YamlUtils}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class YamlUtilsTest {
|
||||
class YamlUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testSuccess_mergeSimpleMaps() {
|
||||
void testSuccess_mergeSimpleMaps() {
|
||||
String defaultYaml = join("one: ay", "two: bee", "three: sea");
|
||||
String customYaml = join("two: dee", "four: ignored");
|
||||
assertThat(mergeYaml(defaultYaml, customYaml)).isEqualTo("{one: ay, two: dee, three: sea}\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_mergeNestedMaps() {
|
||||
void testSuccess_mergeNestedMaps() {
|
||||
String defaultYaml = join("non: ay", "nested:", " blah: tim", " neat: 12");
|
||||
String customYaml = join("nested:", " blah: max", " extra: none");
|
||||
assertThat(mergeYaml(defaultYaml, customYaml))
|
||||
|
@ -42,7 +39,7 @@ public class YamlUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_listsAreOverridden() {
|
||||
void testSuccess_listsAreOverridden() {
|
||||
String defaultYaml = join("non: ay", "list:", " - foo", " - bar", " - baz");
|
||||
String customYaml = join("list:", " - crackle", " - pop var");
|
||||
assertThat(mergeYaml(defaultYaml, customYaml))
|
||||
|
@ -50,14 +47,14 @@ public class YamlUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_mergeEmptyMap_isNoop() {
|
||||
void testSuccess_mergeEmptyMap_isNoop() {
|
||||
String defaultYaml = join("one: ay", "two: bee", "three: sea");
|
||||
assertThat(mergeYaml(defaultYaml, "# Just a comment\n"))
|
||||
.isEqualTo("{one: ay, two: bee, three: sea}\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_mergeNamedMap_overwritesEntirelyWithNewKey() {
|
||||
void testSuccess_mergeNamedMap_overwritesEntirelyWithNewKey() {
|
||||
String defaultYaml = join("one: ay", "two: bee", "threeMap:", " foo: bar", " baz: gak");
|
||||
assertThat(mergeYaml(defaultYaml, "threeMap: {time: money}"))
|
||||
.isEqualTo(join("one: ay", "two: bee", "threeMap: {time: money}"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue