Class GenerateLandingPagesMojoTest
java.lang.Object
com.guinetik.terminaljavadocs.plugin.GenerateLandingPagesMojoTest
Unit tests for
GenerateLandingPagesMojo.
Tests the landing page generation goal including skip behavior, packaging type checks, and site directory creation.
Uses Mockito to mock Maven session and project dependencies, and JUnit's TemporaryFolder for isolated file system operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionorg.junit.rules.TemporaryFolderTemporary directory for test file operations, cleaned up after each test. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetUp()Sets up the test fixture with mocked Maven dependencies.voidVerifies graceful handling when the reactor contains no modules.voidVerifies that the mojo executes successfully for POM packaging.voidVerifies that the mojo exits early for non-POM packaging types.voidVerifies that the mojo exits early without processing when skip=true.voidVerifies that the custom project name parameter is accepted.voidVerifies that the site output directory is created when it doesn't exist.
-
Field Details
-
tempFolder
public org.junit.rules.TemporaryFolder tempFolderTemporary directory for test file operations, cleaned up after each test.
-
-
Constructor Details
-
GenerateLandingPagesMojoTest
public GenerateLandingPagesMojoTest()
-
-
Method Details
-
setUp
Sets up the test fixture with mocked Maven dependencies. Initializes the mojo with default configuration using reflection.- Throws:
Exception- if reflection fails during field injection
-
testMojoSkipsWhenSkipFlagIsTrue
Verifies that the mojo exits early without processing when skip=true.- Throws:
Exception- if reflection or execution fails
-
testMojoSkipsWhenNotPomPackaging
Verifies that the mojo exits early for non-POM packaging types. Landing pages should only be generated for aggregator (pom) projects.- Throws:
Exception- if reflection or execution fails
-
testMojoExecutesForPomProject
Verifies that the mojo executes successfully for POM packaging. Sets up a mock reactor with one module (without reports) to test the scanning logic.- Throws:
Exception- if reflection or execution fails
-
testSiteDirectoryIsCreated
Verifies that the site output directory is created when it doesn't exist. When no staging directory exists, the mojo should create target/site.- Throws:
Exception- if reflection or execution fails
-
testProjectNameIsUsedInPages
Verifies that the custom project name parameter is accepted. The project name is used in the generated landing page headers.- Throws:
Exception- if reflection or execution fails
-
testHandlesEmptyReactorProjects
Verifies graceful handling when the reactor contains no modules. This can occur in single-module projects or during partial builds.- Throws:
Exception- if reflection or execution fails
-