@@ -27,8 +27,13 @@ public void TestingInfrastructure_WebHost_WithWebHostBuilderRespectsCustomizatio
2727 Assert . Equal ( new [ ] { "ConfigureWebHost" , "Customization" , "FurtherCustomization" } , factory . ConfigureWebHostCalled . ToArray ( ) ) ;
2828 Assert . True ( factory . CreateServerCalled ) ;
2929 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+
3237 Assert . True ( factory . CreateHostBuilderCalled ) ;
3338 Assert . False ( factory . CreateHostCalled ) ;
3439 }
@@ -45,7 +50,13 @@ public void TestingInfrastructure_GenericHost_WithWithHostBuilderRespectsCustomi
4550
4651 // Assert
4752 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+
4960 Assert . True ( factory . CreateHostBuilderCalled ) ;
5061 Assert . True ( factory . CreateHostCalled ) ;
5162 Assert . False ( factory . CreateServerCalled ) ;
@@ -128,7 +139,12 @@ public void Dispose()
128139
129140 private class CustomizedFactory < TEntryPoint > : WebApplicationFactory < TEntryPoint > where TEntryPoint : class
130141 {
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.
131146 public bool GetTestAssembliesCalled { get ; private set ; }
147+
132148 public bool CreateWebHostBuilderCalled { get ; private set ; }
133149 public bool CreateHostBuilderCalled { get ; private set ; }
134150 public bool CreateServerCalled { get ; private set ; }
0 commit comments