Skip to content

Commit 7206d2f

Browse files
Merge pull request #352 from TNG/326-tests-may-behave-differently-in-release-configuration
Add Documentation for Async Function Limitations in Release Builds
2 parents e757f27 + 13b7920 commit 7206d2f

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

ExampleTest/LimitationsOnReleaseTest.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System.Linq;
2+
using System.Threading.Tasks;
23
using ArchUnitNET.Domain;
34
using ArchUnitNET.Domain.Extensions;
45
using ArchUnitNET.Loader;
6+
using ArchUnitNET.xUnit;
57
using Xunit;
8+
using static ArchUnitNET.Fluent.ArchRuleDefinition;
69

710
namespace ExampleTest
811
{
@@ -61,6 +64,17 @@ public void TypeOfDependencyTest()
6164

6265
Assert.Contains(_missingDependencyClass, methodWithTypeOfDependencyDependencies);
6366
}
67+
68+
[Fact]
69+
public void AsyncMethodDependencyTest()
70+
{
71+
Classes()
72+
.That()
73+
.Are(typeof(AsyncUser))
74+
.Should()
75+
.CallAny(MethodMembers().That().HaveName("MethodAsync()"))
76+
.Check(Architecture);
77+
}
6478
}
6579

6680
#pragma warning disable 219
@@ -85,5 +99,23 @@ public void MethodWithNullVariable()
8599
internal class MissingDependencyClass { }
86100

87101
internal class SubClass : MissingDependencyClass { }
102+
103+
internal class AsyncService
104+
{
105+
public async Task MethodAsync()
106+
{
107+
await Task.Delay(100);
108+
}
109+
}
110+
111+
internal class AsyncUser
112+
{
113+
private readonly AsyncService _asyncService = new AsyncService();
114+
115+
public async Task UseAsyncService()
116+
{
117+
await _asyncService.MethodAsync();
118+
}
119+
}
88120
}
89121
#pragma warning restore 219

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ namespace ExampleTest
114114
}
115115
```
116116

117+
#### Run the tests
118+
119+
Since ArchUnitNET is reading the architecture form the analyzed binaries, it is recommended to run ArchUnitNET-based tests in Debug configuration.
120+
121+
```
122+
dotnet test -c Debug
123+
```
124+
125+
For more details on known edge cases, see [the documentation](https://archunitnet.readthedocs.io/en/stable/limitations/debug_artifacts/).
126+
117127
#### Further Info and Help
118128

119129
Check out test examples for the current release at

documentation/docs/limitations/debug_artifacts.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
ArchUnitNET gathers information about the architecture from analyzing
33
binaries, therefore running tests with the Release option (`dotnet test -c Release`) instead of the Debug
44
option (`dotnet test -c Debug`) can lead to not finding dependencies you normally would expect to find.
5-
The edge cases we found so far are not initializing a local variable, casting an object and using
6-
the typeof() statement. A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs).
5+
The edge cases we found so far are not initializing a local variable, casting an object, using
6+
the typeof() statement and checking that an async function is called.
7+
A minimal example for each edge case can be found [here](https://github.com/TNG/ArchUnitNET/blob/master/ExampleTest/LimitationsOnReleaseTest.cs).
78

89

910
If you come across another edge case, where executing tests in Debug mode leads to different results than executing

0 commit comments

Comments
 (0)