https://github.com/enofex/taikai
Taikai is an extension of the popular ArchUnit library, offering a comprehensive suite of predefined rules tailored for various technologies.
https://github.com/enofex/taikai
architecture-tests archunit java junit5 logging spring spring-boot testing
Last synced: about 2 months ago
JSON representation
Taikai is an extension of the popular ArchUnit library, offering a comprehensive suite of predefined rules tailored for various technologies.
- Host: GitHub
- URL: https://github.com/enofex/taikai
- Owner: enofex
- License: mit
- Created: 2024-05-31T09:56:25.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-02-22T05:58:47.000Z (about 2 months ago)
- Last Synced: 2025-02-22T06:27:54.745Z (about 2 months ago)
- Topics: architecture-tests, archunit, java, junit5, logging, spring, spring-boot, testing
- Language: Java
- Homepage: https://enofex.github.io/taikai
- Size: 1 MB
- Stars: 130
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-java - Taikai
README
![]()
![]()
![]()
![]()
# Taikai
Taikai extends the capabilities of the popular ArchUnit library by offering a comprehensive suite of predefined rules tailored for various technologies. It simplifies the enforcement of architectural constraints and best practices in your codebase, ensuring consistency and quality across your projects.
## Maven Usage
Add Taikai as a dependency in your `pom.xml`:
```xml
com.enofex
taikai
${taikai.version}
test```
Replace `${taikai.version}` with the appropriate version defined in your project. Ensure that the required dependencies like ArchUnit are already declared.
## Gradle Usage
Add Taikai as a dependency in your `build.gradle` file:
```groovy
testImplementation "com.enofex:taikai:${taikaiVersion}"
```Replace `${taikaiVersion}` with the appropriate version defined in your project. Ensure that the required dependencies like ArchUnit are already declared.
## JUnit 5 Example Test
Here's an example demonstrating the usage of some Taikai rules with JUnit 5. Customize rules as needed using `TaikaiRule.of()`.
```java
@Test
void shouldFulfillConstraints() {
Taikai.builder()
.namespace("com.enofex.taikai")
.java(java -> java
.noUsageOfDeprecatedAPIs()
.methodsShouldNotDeclareGenericExceptions()
.utilityClassesShouldBeFinalAndHavePrivateConstructor()
.imports(imports -> imports
.shouldHaveNoCycles()
.shouldNotImport("..shaded..")
.shouldNotImport("org.junit.."))
.naming(naming -> naming
.classesShouldNotMatch(".*Impl")
.methodsShouldNotMatch("^(?!foo$|bar$).*")
.fieldsShouldNotMatch(".*(List|Set|Map)$")
.fieldsShouldMatch("com.enofex.taikai.Matcher", "matcher")
.constantsShouldFollowConventions()
.interfacesShouldNotHavePrefixI()))
.logging(logging -> logging
.loggersShouldFollowConventions(Logger.class, "logger", List.of(PRIVATE, FINAL)))
.test(test -> test
.junit5(junit5 -> junit5
.classesShouldNotBeAnnotatedWithDisabled()
.methodsShouldNotBeAnnotatedWithDisabled()))
.spring(spring -> spring
.noAutowiredFields()
.boot(boot -> boot
.springBootApplicationShouldBeIn("com.enofex.taikai"))
.configurations(configuration -> configuration
.namesShouldEndWithConfiguration())
.controllers(controllers -> controllers
.shouldBeAnnotatedWithRestController()
.namesShouldEndWithController()
.shouldNotDependOnOtherControllers()
.shouldBePackagePrivate())
.services(services -> services
.shouldBeAnnotatedWithService()
.shouldNotDependOnControllers()
.namesShouldEndWithService())
.repositories(repositories -> repositories
.shouldBeAnnotatedWithRepository()
.shouldNotDependOnServices()
.namesShouldEndWithRepository()))
.addRule(TaikaiRule.of(...)) // Add custom ArchUnit rule here
.build()
.check();
}
```## User Guide
Explore the complete [documentation](https://enofex.github.io/taikai) for comprehensive information on all available rules.
## Contributing
Interested in contributing? Check out our [Contribution Guidelines](https://github.com/enofex/taikai/blob/main/CONTRIBUTING.md) for details on how to get involved. Note, that we expect everyone to follow the [Code of Conduct](https://github.com/enofex/taikai/blob/main/CODE_OF_CONDUCT.md).
### What you will need
* Git
* Java 17 or higher### Get the Source Code
Clone the repository
```shell
git clone [email protected]:enofex/taikai.git
cd taikai
```### Build the code
To compile, test, and build
```shell
./mvnw clean package -B
```## Backers
The Open Source Community
## Website
Visit the [Taikai](https://enofex.github.io/taikai/) Website for general information and documentation.