Class QuarkusCodestartTest
- java.lang.Object
-
- io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension
public class QuarkusCodestartTest extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
This extension helps test a Quarkus extension codestart. It provides a way to test:- the generated project content (with immutable mocked data) using snapshot testing
- the generated project build/run (with real data) with helpers to run the build
Before all tests, the extension will generate Quarkus projects in the specified languages with the given codestart, with mocked data and with real data.
You can find those generated project in `target/quarkus-codestart-test`.
You can open the `real-data` ones in your IDE or play with them using the terminal.
Running those tests is the easiest way to iterate on your extension codestart dev
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)voidafterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext)org.assertj.core.api.AbstractPathAssert<?>assertThatGeneratedFile(QuarkusCodestartCatalog.Language language, String fileRelativePath)Get a PathAssert on a generated mocked file for a specific language
Very usefull to check if a file contains a specific String:
Example:
codestartTest.assertThatGeneratedFile(JAVA, "README.md").satisfies(checkContains("./mvnw compile quarkus:dev -Dquarkus.args='Quarky"));org.assertj.core.api.AbstractPathAssert<?>assertThatGeneratedFileMatchSnapshot(QuarkusCodestartCatalog.Language language, String fileRelativePath)SeeassertThatGeneratedFile(Language language, String fileRelativePath)but also compare it with its snapshotsorg.assertj.core.api.ListAssert<String>assertThatGeneratedTreeMatchSnapshots(QuarkusCodestartCatalog.Language language)This let you compare the project file structure (tree) for a specific language against its snapshotorg.assertj.core.api.ListAssert<String>assertThatGeneratedTreeMatchSnapshots(QuarkusCodestartCatalog.Language language, String dirRelativePath)see {link #assertThatGeneratedTreeMatchSnapshots(Language language)} but for a specific sub directoryvoidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext)voidbuildAllProjects()This will run the build on all generated projects (with real data)static QuarkusCodestartTestBuilderbuilder()voidbuildProject(QuarkusCodestartCatalog.Language language)This will run the build on the generated projects (with real data) in the specified language.org.assertj.core.api.AbstractPathAssert<?>checkGeneratedSource(QuarkusCodestartCatalog.Language language, String className)It will validate (compare and check package name) the class against the snapshots in all the projects for the given languagevoidcheckGeneratedSource(String className)Check that the given full qualified className is valid in all generated projects (with fake data)
SeecheckGeneratedSource(Language language, String className)org.assertj.core.api.AbstractPathAssert<?>checkGeneratedTestSource(QuarkusCodestartCatalog.Language language, String className)It will validate (compare and check package name) the test class against the snapshots in all the projects for the given languagevoidcheckGeneratedTestSource(String className)Check that the given full qualified test className is valid in all generated projects (with fake data)
SeecheckGeneratedSource(Language language, String className)protected List<ResourceLoader>getCodestartsResourceLoaders()io.quarkus.registry.catalog.ExtensionCataloggetExtensionsCatalog()QuarkusCodestartCataloggetQuarkusCodestartCatalog()
-
-
-
Method Detail
-
builder
public static QuarkusCodestartTestBuilder builder()
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
getQuarkusCodestartCatalog
public QuarkusCodestartCatalog getQuarkusCodestartCatalog() throws IOException
- Throws:
IOException
-
getExtensionsCatalog
public io.quarkus.registry.catalog.ExtensionCatalog getExtensionsCatalog()
-
buildAllProjects
public void buildAllProjects() throws IOExceptionThis will run the build on all generated projects (with real data)- Throws:
IOException
-
buildProject
public void buildProject(QuarkusCodestartCatalog.Language language) throws IOException
This will run the build on the generated projects (with real data) in the specified language.- Parameters:
language- the language- Throws:
IOException
-
checkGeneratedSource
public void checkGeneratedSource(String className) throws Throwable
Check that the given full qualified className is valid in all generated projects (with fake data)
SeecheckGeneratedSource(Language language, String className)- Parameters:
className- the full qualified className (using `org.acme.ClassName` also works, it will be replaced by the project package name)- Throws:
Throwable
-
checkGeneratedTestSource
public void checkGeneratedTestSource(String className) throws Throwable
Check that the given full qualified test className is valid in all generated projects (with fake data)
SeecheckGeneratedSource(Language language, String className)- Parameters:
className- the full qualified test class name (using `org.acme.ClassName` also works, it will be replaced by the project package name)- Throws:
Throwable
-
checkGeneratedSource
public org.assertj.core.api.AbstractPathAssert<?> checkGeneratedSource(QuarkusCodestartCatalog.Language language, String className) throws Throwable
It will validate (compare and check package name) the class against the snapshots in all the projects for the given language- Parameters:
language- the language to checkclassName- the full qualified className (using `org.acme.ClassName` also works, it will be replaced by the project package name)- Returns:
- Throws:
Throwable
-
checkGeneratedTestSource
public org.assertj.core.api.AbstractPathAssert<?> checkGeneratedTestSource(QuarkusCodestartCatalog.Language language, String className) throws Throwable
It will validate (compare and check package name) the test class against the snapshots in all the projects for the given language- Parameters:
language- the language to checkclassName- the full qualified test className (using `org.acme.ClassName` also works, it will be replaced by the project package name)- Returns:
- Throws:
Throwable
-
assertThatGeneratedFile
public org.assertj.core.api.AbstractPathAssert<?> assertThatGeneratedFile(QuarkusCodestartCatalog.Language language, String fileRelativePath) throws Throwable
Get a PathAssert on a generated mocked file for a specific language
Very usefull to check if a file contains a specific String:
Example:
codestartTest.assertThatGeneratedFile(JAVA, "README.md").satisfies(checkContains("./mvnw compile quarkus:dev -Dquarkus.args='Quarky"));- Parameters:
language- the languagefileRelativePath- the relative path for the file in the generated project- Returns:
- the PathAssert
- Throws:
Throwable
-
assertThatGeneratedFileMatchSnapshot
public org.assertj.core.api.AbstractPathAssert<?> assertThatGeneratedFileMatchSnapshot(QuarkusCodestartCatalog.Language language, String fileRelativePath) throws Throwable
SeeassertThatGeneratedFile(Language language, String fileRelativePath)but also compare it with its snapshots- Parameters:
language- the languagefileRelativePath- the relative path for the file in the generated project- Returns:
- Throws:
Throwable
-
assertThatGeneratedTreeMatchSnapshots
public org.assertj.core.api.ListAssert<String> assertThatGeneratedTreeMatchSnapshots(QuarkusCodestartCatalog.Language language) throws Throwable
This let you compare the project file structure (tree) for a specific language against its snapshot- Parameters:
language- the language- Returns:
- the ListAssert
- Throws:
Throwable
-
assertThatGeneratedTreeMatchSnapshots
public org.assertj.core.api.ListAssert<String> assertThatGeneratedTreeMatchSnapshots(QuarkusCodestartCatalog.Language language, String dirRelativePath) throws Throwable
see {link #assertThatGeneratedTreeMatchSnapshots(Language language)} but for a specific sub directory- Parameters:
language- the languagedirRelativePath- the sub directory- Returns:
- the ListAssert
- Throws:
Throwable
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
getCodestartsResourceLoaders
protected List<ResourceLoader> getCodestartsResourceLoaders()
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
-