You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add unit testing guidelines to Contribute.md (#114)
* Initial plan
* Add comprehensive testing notes to Contribute.md
Co-authored-by: aholstrup1 <117829001+aholstrup1@users.noreply.github.com>
* Remove E2E testing documentation, keep only unit tests
Co-authored-by: aholstrup1 <117829001+aholstrup1@users.noreply.github.com>
* Update unit test best practices
Removed the guideline to follow the Arrange-Act-Assert pattern from best practices for unit tests.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aholstrup1 <117829001+aholstrup1@users.noreply.github.com>
Copy file name to clipboardExpand all lines: Scenarios/Contribute.md
+69Lines changed: 69 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,10 +43,79 @@ Please ensure that all unit tests run and create a Pull Request against [https:/
43
43
44
44
In the AL-Go repository we use a number of precommit hooks to help us identify issues in the code. We run the precommit hooks locally but also as a PR check. In order to ensure this check passes please install pre-commit in your local AL-Go repository. Pre-Commit can be installed by following the instructions on https://pre-commit.com/#quick-start. Once the precommint hooks are installed you can run `pre-commit run --all-files` to verify your changes.
45
45
46
+
## Testing your contributions
47
+
48
+
When contributing to AL-Go, it's important to add tests for your changes to ensure code quality and prevent regressions.
49
+
50
+
**When to add tests:**
51
+
52
+
-**Always add unit tests** for new functions, modules, or bug fixes
53
+
-**Update existing tests** if you modify existing functionality
54
+
-**Ensure all tests pass** before submitting a pull request
55
+
56
+
Unit tests in AL-Go are fast, isolated tests that verify individual functions and modules using the Pester testing framework.
57
+
58
+
The section below provides detailed guidance on how to add unit tests.
59
+
46
60
## Unit tests
47
61
48
62
The Tests folder, in the AL-Go repository, contains a number of unit-tests. Open Tests/runtests.ps1 in VS Code and select Run. Unit tests are quick and will run on every PR and every Push. We will be adding a lot of unit tests going forward.
49
63
64
+
### How to add unit tests
65
+
66
+
When contributing to AL-Go, you should add unit tests for your changes. Unit tests in AL-Go use the [Pester](https://pester.dev/) testing framework for PowerShell.
67
+
68
+
**Creating a new unit test file:**
69
+
70
+
1. Create a new `.Test.ps1` file in the `Tests` folder. The file name should describe what you're testing (e.g., `MyFeature.Test.ps1`)
71
+
2. Import the module or script you want to test at the beginning of your test file
72
+
3. Use `Describe` blocks to group related tests
73
+
4. Use `It` blocks for individual test cases
74
+
5. Use `BeforeAll` for setup that runs once before all tests in a `Describe` block
75
+
6. Use `Mock` to mock external dependencies and function calls
0 commit comments