Skip to content

Commit

Permalink
Excavator: Switch to JUnit 5 to parallelize tests and speed up CI
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot committed Oct 23, 2024
1 parent 172f486 commit 945cd1c
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion javapoet/src/test/java/ClassNameNoPackageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import com.palantir.javapoet.ClassName;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Since it is impossible to import classes from the default package into other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.JavaFileObject;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public abstract class AbstractTypesTest {
protected abstract Elements getElements();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import java.lang.annotation.Target;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AnnotatedTypeNameTest {

Expand All @@ -38,14 +39,18 @@ public class AnnotatedTypeNameTest {
@Target(ElementType.TYPE_USE)
public @interface TypeUseAnnotation {}

@Test(expected = NullPointerException.class)
@Test
public void nullAnnotationArray() {
TypeName.BOOLEAN.annotated((AnnotationSpec[]) null);
Assertions.assertThrows(NullPointerException.class, () -> {
TypeName.BOOLEAN.annotated((AnnotationSpec[]) null);
});
}

@Test(expected = NullPointerException.class)
@Test
public void nullAnnotationList() {
TypeName.DOUBLE.annotated((List<AnnotationSpec>) null);
Assertions.assertThrows(NullPointerException.class, () -> {
TypeName.DOUBLE.annotated((List<AnnotationSpec>) null);
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.lang.annotation.RetentionPolicy;
import javax.lang.model.element.TypeElement;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;

@SuppressWarnings("ClassCanBeStatic")
public final class AnnotationSpecTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class CodeBlockTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CodeWriterTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import javax.lang.model.element.Modifier;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class FieldSpecTest {
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.common.collect.Iterables;
import com.google.common.io.ByteStreams;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
Expand All @@ -35,18 +36,17 @@
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.io.TempDir;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class FileReadingTest {

// Used for storing compilation output.
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@TempDir
public File temporaryFolder;

@Test
public void javaFileObjectUri() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@
import java.util.Date;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.io.TempDir;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mockito;

@RunWith(JUnit4.class)
public final class FileWritingTest {
// Used for testing java.io File behavior.
@Rule
public final TemporaryFolder tmp = new TemporaryFolder();
@TempDir
public File tmp;

// Used for testing java.nio.file Path behavior.
private final FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.JavaFileObject;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

@SuppressWarnings({"ClassCanBeStatic", "TypeParameterUnusedInFormals", "StrictUnusedVariable", "UnusedMethod"})
public final class MethodSpecTest {
Expand All @@ -55,7 +55,7 @@ public final class MethodSpecTest {
private Elements elements;
private Types types;

@Before
@BeforeEach
public void before() {
elements = compilation.getElements();
types = compilation.getTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public final class NameAllocatorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

@SuppressWarnings({"ClassCanBeStatic", "StrictUnusedVariable"})
public class ParameterSpecTest {
Expand All @@ -41,7 +41,7 @@ public class ParameterSpecTest {

private Elements elements;

@Before
@BeforeEach
public void before() {
elements = compilation.getElements();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.junit.Test;
import org.junit.jupiter.api.Test;

@SuppressWarnings("ClassCanBeStatic")
public class TypeNameTest {
Expand Down
2 changes: 1 addition & 1 deletion javapoet/src/test/java/com/palantir/javapoet/UtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class UtilTest {
@Test
Expand Down

0 comments on commit 945cd1c

Please sign in to comment.