@@ -27,8 +27,13 @@ public void TestingInfrastructure_WebHost_WithWebHostBuilderRespectsCustomizatio
27
27
Assert . Equal ( new [ ] { "ConfigureWebHost" , "Customization" , "FurtherCustomization" } , factory . ConfigureWebHostCalled . ToArray ( ) ) ;
28
28
Assert . True ( factory . CreateServerCalled ) ;
29
29
Assert . True ( factory . CreateWebHostBuilderCalled ) ;
30
- // GetTestAssemblies is not called when reading content roots from MvcAppManifest
31
- Assert . False ( factory . GetTestAssembliesCalled ) ;
30
+
31
+ // When run locally on the developer machine, the test manifest will be generated,
32
+ // and the content root will be read from the manifest file.
33
+ // However, when run in CI, the relative path in the metadata will not exist,
34
+ // and the content root lookup logic will probe the test assemblies too.
35
+ //Assert.False(factory.GetTestAssembliesCalled);
36
+
32
37
Assert . True ( factory . CreateHostBuilderCalled ) ;
33
38
Assert . False ( factory . CreateHostCalled ) ;
34
39
}
@@ -45,7 +50,13 @@ public void TestingInfrastructure_GenericHost_WithWithHostBuilderRespectsCustomi
45
50
46
51
// Assert
47
52
Assert . Equal ( new [ ] { "ConfigureWebHost" , "Customization" , "FurtherCustomization" } , factory . ConfigureWebHostCalled . ToArray ( ) ) ;
48
- Assert . False ( factory . GetTestAssembliesCalled ) ;
53
+
54
+ // When run locally on the developer machine, the test manifest will be generated,
55
+ // and the content root will be read from the manifest file.
56
+ // However, when run in CI, the relative path in the metadata will not exist,
57
+ // and the content root lookup logic will probe the test assemblies too.
58
+ //Assert.False(factory.GetTestAssembliesCalled);
59
+
49
60
Assert . True ( factory . CreateHostBuilderCalled ) ;
50
61
Assert . True ( factory . CreateHostCalled ) ;
51
62
Assert . False ( factory . CreateServerCalled ) ;
@@ -128,7 +139,12 @@ public void Dispose()
128
139
129
140
private class CustomizedFactory < TEntryPoint > : WebApplicationFactory < TEntryPoint > where TEntryPoint : class
130
141
{
142
+ // GetTestAssemblies is not called when reading content roots from MvcAppManifest,
143
+ // and the content root specified in the manifest is a path that exists.
144
+ // Otherwise, the WebApplicationFactory will try to look for the referenced assemblies which have
145
+ // `WebApplicationFactoryContentRootAttribute` applied to them, to extract the content root path from that metadata.
131
146
public bool GetTestAssembliesCalled { get ; private set ; }
147
+
132
148
public bool CreateWebHostBuilderCalled { get ; private set ; }
133
149
public bool CreateHostBuilderCalled { get ; private set ; }
134
150
public bool CreateServerCalled { get ; private set ; }
0 commit comments