@CheckReturnValue
See: Description
| Interface | Description |
|---|---|
| CompileTester |
The root of the fluent API for testing the result of compilation.
|
| CompileTester.ChainingClause<T> |
The clause in the fluent API that allows for chaining test conditions.
|
| CompileTester.CleanCompilationClause |
The clause in the fluent API for further tests on successful compilations without warnings.
|
| CompileTester.ColumnClause<T> |
The clause in the fluent API that checks that a diagnostic starts at a particular
column.
|
| CompileTester.CompilationWithNotesClause<T> |
The clause in the fluent API that checks notes in a compilation.
|
| CompileTester.CompilationWithWarningsClause<T> |
The clause in the fluent API that checks notes and warnings in a compilation.
|
| CompileTester.FileClause<T> |
The clause in the fluent API that checks that a diagnostic is associated with a particular
JavaFileObject. |
| CompileTester.GeneratedPredicateClause<T> |
The clause in the fluent API that checks that files were generated.
|
| CompileTester.LineClause<T> |
The clause in the fluent API that checks that a diagnostic is on a particular
line.
|
| CompileTester.SuccessfulCompilationClause |
The clause in the fluent API for further tests on successful compilations.
|
| CompileTester.SuccessfulFileClause<T> |
The clause in the fluent API that checks that a generated file has the specified contents.
|
| CompileTester.UnsuccessfulCompilationClause |
The clause in the fluent API for further tests on unsuccessful compilations.
|
| ProcessedCompileTesterFactory |
Creates
CompileTester instances that test compilation with provided Processor
instances. |
| Class | Description |
|---|---|
| Compilation |
The results of compiling source files.
|
| CompilationRule | |
| CompilationSubject |
A
Truth subject for a Compilation. |
| Compiler |
An object that can
Compiler.compile(javax.tools.JavaFileObject...) Java source files. |
| ForwardingStandardJavaFileManager |
Forwards calls to a given
StandardJavaFileManager. |
| JavaFileObjects |
A utility class for creating
JavaFileObject instances. |
| JavaFileObjectSubject |
Assertions about
JavaFileObjects. |
| JavaSourcesSubject | |
| JavaSourcesSubject.SingleSourceAdapter | |
| JavaSourcesSubjectFactory | |
| JavaSourceSubjectFactory |
A Truth
Subject.Factory similar to
JavaSourcesSubjectFactory, but for working with single source files. |
| Parser |
Methods to parse Java source files.
|
| Enum | Description |
|---|---|
| Compilation.Status |
The status of a compilation.
|
| Exception | Description |
|---|---|
| CompilationFailureException |
An exception thrown to indicate that compilation has failed for an unknown reason.
|
javac or creating separate integration test
projects.
Compiler lets you choose command-line options, annotation processors, and source
files to compile.
Compilation represents the immutable result of compiling source files: diagnostics
and generated files.
CompilationSubject lets you make assertions about Compilation objects.
JavaFileObjectSubject lets you make assertions about JavaFileObject objects.
A simple example that tests that compiling a source file succeeded is:
Compilation compilation =
javac().compile(JavaFileObjects.forSourceString("HelloWorld", "final class HelloWorld {}");
assertThat(compilation).succeeded();
A similar example that tests that compiling a source file with an annotation processor succeeded without errors or warnings (including compiling any source files generated by the annotation processor) is:
Compilation compilation =
javac()
.withProcessors(new MyAnnotationProcessor())
.compile(JavaFileObjects.forSourceString("HelloWorld", "final class HelloWorld {}");
assertThat(compilation).succeededWithoutWarnings();
You can make assertions about the files generated during the compilation as well. For example, the following snippet tests that compiling a source file with an annotation processor generates a source file equivalent to a golden file:
Compilation compilation =
javac()
.withProcessors(new MyAnnotationProcessor())
.compile(JavaFileObjects.forResource("HelloWorld.java"));
assertThat(compilation).succeeded();
assertThat(compilation)
.generatedSourceFile("GeneratedHelloWorld")
.hasSourceEquivalentTo(JavaFileObjects.forResource("GeneratedHelloWorld.java"));
You can also test that errors or other diagnostics were reported. The following tests that compiling a source file with an annotation processor reported an error:
JavaFileObject helloWorld = JavaFileObjects.forResource("HelloWorld.java");
Compilation compilation =
javac()
.withProcessors(new NoHelloWorld())
.compile(helloWorld);
assertThat(compilation).failed();
assertThat(compilation)
.hadErrorContaining("No types named HelloWorld!")
.inFile(helloWorld)
.onLine(23)
.atColumn(5);
Copyright © 2013–2022. All rights reserved.