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!
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.
Accept and Review Generated Tests
After accepting the generated tests, we need to review and modify them to suit our requirements.
Refactor Test Naming Conventions
We start by renaming our test files from test
to spec
for better clarity and organization.
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.
Remove Assignable Errors
Sometimes the error messages need to be more specific. Ensure that error names are appropriate for the context.
Renaming and Correcting All Relevant Parts
Go through all instances and rename them accordingly to maintain readability and consistency.
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.
Final Verification
Once all modifications and necessary refactorings are done, verify that all tests pass.
spec
.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!