crashtestdev
02/13/2024, 10:03 AMc#
[TestFixture]
public class UsersControllerTests : UmbracoTestServerTestBase
{
[Test]
public async Task EnsureSuccessStatusCode()
{
}
}
This seems to fail every time, showing a load of services failed to be created:
System.AggregateException : Some services are not able to be constructed
If I change the inherited type to UmbracoIntegrationTest this however runs fine. Is there extra steps I am missing to get this to work?crashtestdev
02/14/2024, 9:54 AMSystem.InvalidOperationException : Can't find 'C:\Development\LearningUmbraco\MyProject.IntegrationTests\bin\Debug\net7.0\Umbraco.Tests.Integration.deps.json'. This file is required for functional tests to run properly. There should be a copy of the file on your source project bin folder. If that is not the case, make sure that the property PreserveCompilationContext is set to true on your project file. E.g '<PreserveCompilationContext>true</PreserveCompilationContext>'. For functional tests to work they need to either run from the build output folder or the Umbraco.Tests.Integration.deps.json file from your application's output directory must be copied to the folder where the tests are running on. A common cause for this error is having shadow copying enabled when the tests run.
I tried setting <PreserveCompilationContext>true</PreserveCompilationContext>
in my csproj, this didn't make a difference, there doesn't seem to be a Umbraco.Tests.Integration.deps.json
, I have noticed there's an active GH bug https://github.com/umbraco/Umbraco-CMS/issues/14554 that says the file instead named for some reason {MyProjectsName}.deps.json
, I have checked and there is a file by that name, I will try and just rename this file and see how that works.crashtestdev
02/14/2024, 10:22 AMbin/Debug/{.net version}/{your project name}.deps.json
to Umbraco.Tests.Integration.deps.json
Domitnator
02/14/2024, 1:14 PMLars-Erik
02/15/2024, 10:06 AMUmbracoTestServerTestBase
thing starts a webserver, so you'll have to call the controllers to interact with it. The services will be there in the hosted code.
If you want to test your code "in process" with the tests, you'll wanna use the UmbracoIntegrationTest
base.