Open dwekwejt opened 2 years ago
Hi @dwekwejt ,
Could you please share Model
, Controller
and IService
so I can try to investigate this? (Doesn't have to be the actual code, just something that reproduces the issue in the DevOps env.)
Also does this occur if the DevOps env just runs that single test? If there are other tests it could be a problem with an arg matcher in a previous test.
Hi,
I'm having the same problem overriding an IOptions
The first initialization works correctly and when performing a second test I get the same error as you.
Sincerely,
So I'm also having this issue. It was in a larger project where I was converting from Moq to NSubstitute. First time using NSubstitute and I suspect that I did something wrong.
Though in playing around with it, I discovered that I could recreate the issue locally by changing the way XUnit handled threads.
I created and AssemblyInfo.cs file for the test project and added this.
using System.Runtime.InteropServices; using Xunit;
// In SDK-style projects such as this one, several assembly attributes that were historically // defined in this file are now automatically added during build and populated with // values defined in project properties. For details of which attributes are included // and how to customise this process see: https://aka.ms/assembly-info-properties
// Setting ComVisible to false makes the types in this assembly not visible to COM // components. If you need to access a type in this assembly from COM, set the ComVisible // attribute to true on that type.
[assembly: ComVisible(false)] [assembly: CollectionBehavior(DisableTestParallelization = true)]
In order to get ADO (azure dev ops) to build the test project, i had to modify the project and add the GenerateAssemblyInfo element and set it to false like below.
I will be taking a more careful look at the documents and slowing converting this project, if i happens again I will update.
@cyrusdowney Thank you for the info! Is there a chance you can share the test with us so that we can reproduce it locally?
No. There were a few hundred tests and it felt like my approach of converting everything at once was to much. So I took a step back and started over. I'm hoping that by slowly converting I can nail down the issue (create a reproduction for you etc.)
@cyrusdowney Is it OK to close this issue?
I will be taking a more careful look at the documents and slowing converting this project, if i happens again I will update.
Free free to re-open when you have more info on this one
Yep, I was not able to reproduce it and got though all the tests. Found multiple places where arg. Was used incorrectly, so who knows
Describe the bug I've got an UnexpectedArgumentMatcherException on my DevOps environment. I don't have it on my local computer.
To Reproduce
Please make sure you are using NSubstitute.Analyzers and that it does not pick up any problems with the reproduction code. The analyzers can help detect the cause of many issues.
Expected behaviour There shouldn't be any error on DevOps env.
Environment:
Additional context