Building and Testing
This document provides instructions for building and testing the Kotatsu Parsers library. It explains how to set up your development environment, build the project, and run the automated test suite to validate parser functionality.
For information about adding new parsers, see Contributing and Adding a New Parser.
Setting Up the Development Environment
Before building the project, ensure you have the following prerequisites installed:
- JDK 8 or newer
- Gradle (or use the included Gradle wrapper) The project uses Kotlin 2.0.20 and the Kotlin Symbol Processing (KSP) plugin for annotation processing.
Building the Project
To build the project, run the Gradle build command from the project root directory:
For just compiling without running tests:
The build process involves:
- Compiling the Kotlin code
- Processing annotations with KSP
- Running tests
- Generating the library JAR file
The build will generate:
- Library JAR in
build/libs/
- KSP outputs in
build/generated/ksp/
- Test reports in
build/reports/tests/
Testing Framework
Kotatsu Parsers uses JUnit 5 (Jupiter) for testing. The main test class MangaParserTest
provides a comprehensive test suite that validates all manga parsers against a common specification.
Test Configuration
Tests are configured in the build.gradle
file:
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.1'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2'
testImplementation 'io.webfolder:quickjs:1.1.0'
}
test {
useJUnitPlatform()
}
Running Tests
To run tests for all parsers:
To run tests for a specific parser, you can use the test filter:
Test Report Generation
The project includes a custom test report generator that creates HTML reports from test results:
This task processes the XML test results and generates a more readable HTML report showing test status for each parser.
What the Tests Validate
The test suite validates each parser's implementation across multiple aspects:
Test Method | Description |
---|---|
list |
Verifies that the parser can retrieve a list of manga |
pagination |
Checks that pagination works correctly |
searchByTitleName |
Tests search functionality by manga title |
tags |
Verifies tag filtering |
tagsMultiple |
Tests filtering by multiple tags |
locale |
Validates locale-based filtering |
details |
Ensures manga details are correctly parsed |
pages |
Verifies chapter page retrieval |
favicon |
Checks for correct favicon parsing |
domain |
Validates domain configuration |
link |
Tests link resolution |
authorization |
Validates authorization if applicable (disabled by default) |
Each test method is annotated with @ParameterizedTest
and @MangaSources
, which runs the test against all supported manga sources.
Continuous Integration
The project uses GitHub Actions for continuous integration. The workflow defined in .github/workflows/test-parsers.yml
runs tests automatically when changes are made to parser implementations.
The CI workflow:
- Checks out the code
- Sets up Java 11
- Builds the project
- Runs tests
This ensures that all changes to parsers are validated before merging.
Common Testing Issues
When implementing or modifying parsers, be aware of these common issues:
- Timeout Errors: Tests have a timeout of 2 minutes. If a parser takes too long to respond, the test will fail.
- Domain Validation: Tests verify that the configured domain matches the actual domain used in HTTP requests.
- Response Format: Tests verify that manga, chapters, and pages have the expected structure and fields.
- Distinct Values: Chapter IDs, Manga IDs, and other identifiers must be unique within their respective collections.
- Source Consistency: All items returned by a parser must have the correct source identifier.
The test suite includes comprehensive validation to catch these and other issues.
Publishing
The project includes Maven publishing configuration to publish the library as a Maven artifact:
afterEvaluate {
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
}
To publish the library: