Integration tests generation and fixes

Integration Testing

In this session, we will walk through creating integration tests for our business logic within the Equity Management Service using GitHub Copilot. Let's get started!

Step-by-Step Guide

  1. Generate Tests using GitHub Copilot

    First, we leverage GitHub Copilot to generate some initial tests. Copilot can create tests based on chai, sinon, and mocha, ensuring consistency with our previous examples.

  2. Accept and Review Generated Tests

    After accepting the generated tests, we need to review and modify them to suit our requirements.

  3. Refactor Test Naming Conventions

    We start by renaming our test files from test to spec for better clarity and organization.

  4. Fix Issues in the Test Implementation

    Upon reviewing, we might find some issues in the test. If Copilot suggests appropriate fixes, those can be implemented directly.

  5. Remove Assignable Errors

    Sometimes the error messages need to be more specific. Ensure that error names are appropriate for the context.

  6. Renaming and Correcting All Relevant Parts

    Go through all instances and rename them accordingly to maintain readability and consistency.

  7. Handle Special Test Conditions

    Some tests, like those checking share splits, are more complex. GitHub Copilot might suggest checking if the shareholder companies' owned amount is correctly updated. For such cases, we challenge students to solve these independently, enhancing their problem-solving skills.

  8. Final Verification

    Once all modifications and necessary refactorings are done, verify that all tests pass.

Key Points to Remember

  • Test File Naming: Use descriptive filenames like spec.
  • Error Message Specificity: Ensure error messages are appropriately named and convey the correct information.
  • Student Challenges: Include sections that challenge students to implement certain parts, aiding in learning.

Conclusion

Creating robust integration tests using tools like GitHub Copilot can streamline the development process. By following the above steps, we ensure comprehensive coverage and correctness in our Equity Management Service. Happy Testing!


Resources