Andulir is a minimalistic, collaborative API automation testing tool designed for Spring Boot
and Spring Cloud
. It is tailored for small development teams and individual developers, aiming to streamline the API testing process.
With Andulir, you can:
- Easily annotate the APIs you want to test.
- Automatically generate data for testing once the project is running locally.
- View test results directly in the console.
Andulir uses a configuration file, atest.xml
, to manage all test cases. If the test results are unsatisfactory, you can modify them in this file. The changes will persist, and previous test cases will re-run the next time the project is launched.
After testing an API, you can change its tag
in atest.xml
to ignore the test case. You can also manage the file with version control tools like git
, allowing your teammates or front-end developers to conveniently share API test cases, reducing communication and testing costs.
Before deploying the project to production, all test cases managed by developers can be tested together, making Andulir a valuable part of your CI/CD pipeline.
In the project root directory, clone the repository:
git clone https://github.com/Werun-backend/Andulir.git
In IntelliJ IDEA, add Andulir as a module:
- Go to
File -> New -> Module From Existing Sources
. - Select
andulir.iml
in the "Select File or Directory to Import" window (important). - Refresh Maven to import the necessary dependencies.
Add Andulir as a dependency in the pom.xml
of the module where you want to use it:
<dependency>
<groupId>org.andulir</groupId>
<artifactId>andulir</artifactId>
<version>0.0.1</version>
</dependency>
Andulir aims to keep configuration minimal. The only necessary configuration is in the application.yml
file, where you specify the project path and controller package location:
andulir:
scan-package: org.andulir.controller
Use the @ATest
annotation to mark methods in the Controller
layer that you want to test, specifying the number of test cases:
@RestController
public class TestController {
@ATest(2)
public void test(List<User> users, Integer integer) {
System.out.println("test");
}
}
After marking enough APIs, you can start Andulir by calling AndulirApplication.start()
in the main
method:
import org.andulir.AndulirApplication;
public class ExampleControllerTest {
public static void main(String[] args) {
AndulirApplication.start(args);
}
}
After starting, an atest.xml
file will appear in the project directory (it will be auto-generated if not present), with generated XML content based on annotated methods. Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<aTest>
<controllerMapping name="com.andulir.controller.TestController">
<methodMapping name="test" status="2">
...
</methodMapping>
</controllerMapping>
</aTest>
The structure of the XML file includes:
<aTest>
as the root tag.<controllerMapping>
showing the method'sController
class.<methodMapping>
containing specific information about the method.
On the first run, Andulir will generate the file and test methods with status=1
, outputting results to the console.
After initial testing, you may find:
- The generated test data is suitable; change
status
to 0, marking it as complete. - The test data needs modification; adjust data in
atest.xml
, restart the project, and retest.
Manage the atest.xml
file with other files using git
or similar tools for unified version control.
Andulir comprises three core components: the Parser, Generator, and Tester, which interact with the atest.xml
file.
The Parser analyzes annotated interfaces and generates corresponding XML tags, storing them in the file. It currently supports basic types, List
, custom request types, and their nesting.
The Generator produces data based on the parsed types, using reflection and the Podam library.
The Tester reads the XML file, generates corresponding methods, and performs tests. Unlike conventional HTTP-based API testing, Andulir accesses methods directly, making it suitable for local testing.
- AndulirConfig: Manually injects necessary beans.
- AndulirProperty: Supports configuration in
application.yml
. - Utilities: Various utility classes required by the program.
Instead of relying solely on annotations, Andulir could detect modified interfaces through git diff
, facilitating fully automated testing.
Better support for nested List<>
types and complex parameters.
Uploading Andulir to a Maven repository for easier imports.
Enhance error handling and fault tolerance.
Automate interface testing before deployment with Jenkins or GitHub Actions.
Add support for mocking dependencies to further simplify testing.
Andulir was born from the simple needs of everyday development. Its goal is to help small teams and individual developers build robust DevOps processes with ease.
If you'd like to contribute, please contact me at [email protected].