Giter VIP home page Giter VIP logo

archunit's Introduction

Architecture Test Framework For Go Project

GitHub Go Reference Build coverage

What is ArchUnit

ArchUnit is a simple and flexible extensible library for checking the architecture of Golang project. with it, you can make your project's architecture visible, testable and stable by setting a set of predefined architectural rules.

Features

  • This project is inspired by the java version ArchUnit, which has been proven best practice in Java
  • Fully tested and easy to use, it can be used any other popular go test frameworks.
  • NRTW(No Reinventing The Wheel). Keep using builtin golang toolchain at most.

Why architecture test matters?

  1. Maintaining architectural integrity: Architecture tests help ensure that the intended architectural design and principles are followed throughout the development process. They help prevent architectural decay and ensure that the system remains consistent and maintainable over time.
  2. Detecting architectural violations: Architecture tests can identify violations of architectural rules and constraints. They help catch issues such as circular dependencies, improper layering, or violations of design patterns. By detecting these violations early, developers can address them before they become more difficult and costly to fix.
  3. Enforcing best practices: Architecture tests can enforce best practices and coding standards. They can check for adherence to coding conventions, naming conventions, and other guidelines specific to the architectural style or framework being used. This helps maintain a consistent codebase and improves code quality.
  4. Supporting refactoring and evolution: Architecture tests provide confidence when refactoring or making changes to the system. They act as a safety net, ensuring that the intended architectural structure is not compromised during the refactoring process. This allows developers to make changes with more confidence, knowing that they won't introduce unintended side effects.
  5. Facilitating collaboration: Architecture tests serve as a form of documentation that communicates the intended architectural design to the development team. They provide a shared understanding of the system's structure and help facilitate collaboration among team members. Developers can refer to the tests to understand the architectural decisions and constraints in place.

How to Use

  • Import the library
go get github.com/kcmvp/archunit
  • Write a simple test
func TestAllPackages(t *testing.T) {
   pkgs := AllPackages().packages()
   assert.Equal(t, 12, len(pkgs))
   err := AllPackages().NameShouldBeSameAsFolder()
   assert.NotNil(t, err)
}

Principles apply to all checks

  • All the checks return an error when it fails, nil error stands for success
  • The error contains detail information about the failure
  • Two steps to define a check
    • Define the criteria of the objects to be checking
    • Apply rules

All Checks

Roadmap

  • Package checks
    • Dependency checks
    • Naming checks
  • Project Layout checks
  • Method checks

archunit's People

Contributors

kcmvp avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

archunit's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.