Skip to content

Commit 4e75290

Browse files
committed
Initial commit
0 parents  commit 4e75290

File tree

127 files changed

+4202
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+4202
-0
lines changed

.config/dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-outdated-tool": {
6+
"version": "4.6.8",
7+
"commands": [
8+
"dotnet-outdated"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
applyTo: '**/*Tests.cs'
3+
---
4+
5+
- Unit tests are written with xUnit 3
6+
- Unit tests follow the naming convention for test driven development using given, when, then.
7+
- The words "given", "when" and "then" are always included as comments in the test method. The code for "given" and "when" may be combined if it fits on a single line, but "then" should always be separate.
8+
- The test method names should be descriptive and begin with the word "Should" to indicate the expected behavior. For example, "ShouldReturnTrueWhenConditionIsMet".
9+
- The variable upon which is asserted should be named "result" to indicate the value being tested.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
appsettings-schema.json
2+
appsettings-schema.*.json
3+
umbraco-package-schema.json
4+
5+
[Bb]in
6+
[Oo]bj

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Umbraco 16 automated testing setup
2+
3+
This project is a fully functioning setup for automated testing with Umbraco 16. You can use this project as a reference or starting point to get started with testing on your Umbraco website. The tests are set up with Test Driven Development (TDD) in mind.
4+
5+
## Tools
6+
7+
The most important tools that are used in the automated tests are as follows:
8+
9+
| Name | Description |
10+
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11+
| [xUnit v3](https://xunit.net/?tabs=cs) | The testing framework. You can use any testing framework that you like though |
12+
| [NSubstitute](https://nsubstitute.github.io/) | Library for mocking. Any mocking library will work. This project doesn't do extensive mocking, but for example `IPublishedValueFallback` is a mandatory parameter for any published content item, even if you don't actually use it. It's just convenient to insert a mock. |
13+
| [Test Containers](https://testcontainers.com/) | Automatically creates docker containers while running tests. It is used to create an empty SQL Server database that is automatically cleaned up after testing. It is required to have **Docker Desktop** installed and running while running these tests. |
14+
15+
For a more exhaustive list of tools, I recommend checking out the .csproj files in each testing project.
16+
17+
## How to use this project
18+
19+
Use this project as a reference to understand how to get started with automated testing in an Umbraco website. Each testing project contains its own readme that explains what things it demonstrates and which files you should check out.
20+
21+
- [Unit testing project](./test/TestingExample.Website.UnitTests/)
22+
- [Integration testing project](./test/TestingExample.Website.IntegrationTests/)
23+
24+
## Running this project locally
25+
26+
Running the tests on your own computer is a good way to get familiar with automated testing. Make sure that you install [Docker](https://www.docker.com/) on your PC and ensure that Docker is running. Clone this repository and run the following command to run the tests:
27+
28+
```
29+
dotnet test
30+
```
31+
32+
Alternatively, you can use your automated test explorer in your IDE.

TestingExample.sln

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingExample.Website", "src\TestingExample.Website\TestingExample.Website.csproj", "{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0C88DD14-F956-CE84-757C-A364CCF449FC}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingExample.Website.UnitTests", "test\TestingExample.Website.UnitTests\TestingExample.Website.UnitTests.csproj", "{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingExample.Website.IntegrationTests", "test\TestingExample.Website.IntegrationTests\TestingExample.Website.IntegrationTests.csproj", "{0B6A2F7A-D866-4149-861F-21BCCB283B61}"
15+
EndProject
16+
Global
17+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
Debug|Any CPU = Debug|Any CPU
19+
Debug|x64 = Debug|x64
20+
Debug|x86 = Debug|x86
21+
Release|Any CPU = Release|Any CPU
22+
Release|x64 = Release|x64
23+
Release|x86 = Release|x86
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Debug|x64.ActiveCfg = Debug|Any CPU
29+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Debug|x64.Build.0 = Debug|Any CPU
30+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Debug|x86.ActiveCfg = Debug|Any CPU
31+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Debug|x86.Build.0 = Debug|Any CPU
32+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Release|x64.ActiveCfg = Release|Any CPU
35+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Release|x64.Build.0 = Release|Any CPU
36+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Release|x86.ActiveCfg = Release|Any CPU
37+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E}.Release|x86.Build.0 = Release|Any CPU
38+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Debug|x64.ActiveCfg = Debug|Any CPU
41+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Debug|x64.Build.0 = Debug|Any CPU
42+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Debug|x86.ActiveCfg = Debug|Any CPU
43+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Debug|x86.Build.0 = Debug|Any CPU
44+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
45+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Release|x64.ActiveCfg = Release|Any CPU
47+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Release|x64.Build.0 = Release|Any CPU
48+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Release|x86.ActiveCfg = Release|Any CPU
49+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3}.Release|x86.Build.0 = Release|Any CPU
50+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Debug|x64.ActiveCfg = Debug|Any CPU
53+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Debug|x64.Build.0 = Debug|Any CPU
54+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Debug|x86.ActiveCfg = Debug|Any CPU
55+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Debug|x86.Build.0 = Debug|Any CPU
56+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Release|x64.ActiveCfg = Release|Any CPU
59+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Release|x64.Build.0 = Release|Any CPU
60+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Release|x86.ActiveCfg = Release|Any CPU
61+
{0B6A2F7A-D866-4149-861F-21BCCB283B61}.Release|x86.Build.0 = Release|Any CPU
62+
EndGlobalSection
63+
GlobalSection(SolutionProperties) = preSolution
64+
HideSolutionNode = FALSE
65+
EndGlobalSection
66+
GlobalSection(NestedProjects) = preSolution
67+
{07BCB56F-FFB1-482B-BCC2-928C98D1DE4E} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
68+
{5BAE0075-20C7-4CDA-B45D-C309FB036BB3} = {0C88DD14-F956-CE84-757C-A364CCF449FC}
69+
{0B6A2F7A-D866-4149-861F-21BCCB283B61} = {0C88DD14-F956-CE84-757C-A364CCF449FC}
70+
EndGlobalSection
71+
EndGlobal

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "9.0.302"
4+
}
5+
}

0 commit comments

Comments
 (0)