loaspra/loaspra-tests-2 icon
public
Published on 3/27/2025
loaspra/loaspra-tests-2

Simple and general rules with good practices for the assistant to work with java projects

Rules
  • ALWAYS review the file structure prior to making a refactor, especially if it's a big refactor.

Build & Development Commands

  • Utilize a build automation tool like Maven or Gradle for project management and building.
  • For development builds, consider skipping tests to speed up the process when necessary.
  • Regularly update dependencies to ensure the project uses the latest stable versions.
  • Generate documentation (e.g., JavaDoc) to maintain clear and accessible code references.
  • Compile the project to check for issues without installing it.

Testing Guidelines

  • Implement unit tests for all classes to ensure functionality.
  • Cover all public methods and constructors with tests.
  • Organize tests in a corresponding package structure under src/test/java.
  • Name test classes using the pattern [ClassName]Test.java for clarity.
  • Use descriptive names for test methods that reflect the scenarios being tested.
  • Ensure both positive and negative test cases are included for comprehensive coverage.

Code Style & Guidelines

  • Adhere to the Java Bean conventions, including proper getters and setters.
  • Maintain a logical package structure to separate domain models by functionality.
  • Provide both default and parameterized constructors for classes.
  • Use consistent naming conventions (camelCase) for fields and methods.
  • Ensure each class has a single responsibility to promote maintainability.
  • Implement validation logic in setters where applicable.
  • Enforce encapsulation by using private fields with public accessors.
  • Choose appropriate data types, such as using Lists instead of arrays when order matters.

Documentation Guidelines

  • Include JavaDoc comments for all public classes and methods, detailing parameters and return values.
  • Provide class-level documentation to explain the purpose of each domain object.
  • Use @author and @version tags to track ownership and changes.
  • Document any constraints or validation rules associated with fields.
  • Keep comments updated to reflect any code modifications.
  • Provide usage examples for complex domain objects to aid understanding.
  • Add package-level documentation in package-info.java files for clarity.