AspNetCore test fail with Specflow Runner on missing deps.json file

36 views
Skip to first unread message

N Jannink

unread,
Sep 7, 2020, 10:40:16 AM9/7/20
to SpecRun
I have specflow tests that use the WebApplicationFactory to mock the server. These test run fine with the Specflow.MsTest runner also in my Azure DevOps pipeline.

But when I switch to the SpecRun.SpecFlow package the test fail with the following error:

Can't find'D:\Projects\xxxx\SpecFlowPlusRunner\netcoreapp3.1\MyApp.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  MyApp.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.

Any idea how to fix this?

N Jannink

unread,
Sep 7, 2020, 11:49:18 AM9/7/20
to SpecRun
When I do this the exception is gone, but maybe there is a better way to achieve this?

private void CopyDepsFile(Assembly assembly) 
{     
    var depsFile = $@"{Path.GetFileNameWithoutExtension(assembly.GetName().Name)}.deps.json";     
    var file = Path.Combine(Folder, depsFile);     
    var destination = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location)!, depsFile);     
    File.Copy(file, destination, true); 

Andreas Willich

unread,
Sep 8, 2020, 3:52:02 AM9/8/20
to SpecRun
Please create an issue at https://github.com/SpecFlowOSS/SpecFlow

--
You received this message because you are subscribed to the Google Groups "SpecRun" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specrun+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/specrun/2375d15a-b2b8-4b24-8d8f-c707dd4a3130n%40googlegroups.com.

N Jannink

unread,
Sep 8, 2020, 11:57:41 AM9/8/20
to SpecRun
Reply all
Reply to author
Forward
0 new messages