docs/5-software-development-practices/5.5.5-test-automation.md | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Automated testing is a crucial step to ensure code quality because developed tests are guaranteed to run once new source code is committed. GitHub Actions is a tool that can help us leverage our tests in a build step. With a testing stage in GitHub Actions, code quality can be ensured by automatically running the tests that have been written. If tests fail, the build can be marked as unstable and deployment will not occur.
?> If you want to test the creation or alteration of a GitHub workflow before committing it, you can use a tool called ACT
- Create a new workflow,
test
, like you did for thegetting-started
workflow in theGitHub Actions
section of the bootcamp. - Set up this workflow to run whenever code changes are pushed to any branch of your repository
- Create jobs for the workflow:
Setup
- Setup the Go LanguageTest
- Run your Unit Tests, make sure this job depends on theSetup
job
- Commit and push the changes
- Go to the Actions tab on your repository fork and verify that
test
workflow ran successfully.
- Open up your
getting-started
workflow that you created in theGitHub Actions
section of the bootcamp. - Edit this workflow to include the
Test
andSetup
jobs you created in Exercise 1 as part of this workflow - Alter the existing
simple
job to depend on theTest
job completing successfully. - Commit and push the changes to your
getting-started
workflow. - Go to the Actions tab on your repository fork and verify that
build
workflow ran successfully.
- Update the
README.md
to include a workflow status badge for yourtest
workflow.
- Discuss the positives of having your testing built into an automation tool such as GitHub Actions
- Discuss the benefits of having workflow badges on your projects