What causes the message "Approvals is not set up to use your test framework."?
We have an ApprovalTests-based unit test that is failing in a nightly remote team build with the following exception:
This unit test passes fine in a local VS2010 unit test run (i.e., mstest). It also passes fine in a remote team "checkin" build (that is run with every code checkin).
We have logged some diagnostic information at the beginning of the test to identify the ApprovalTests.dll assembly that is in-play...
--------------------
ApprovalTests, Version=1.21.4657.21485, Culture=neutral, PublicKeyToken=11bd7d124fc62e0f:
CodeBase = file:///E:/BldSrc/27/305/TestResults/NightlyBuild/Client[2]/Out/ApprovalTests.DLL
FullName = ApprovalTests, Version=1.21.4657.21485, Culture=neutral, PublicKeyToken=11bd7d124fc62e0f
GlobalAssemblyCache = False
ImageRuntimeVersion = v4.0.30319
Location = E:\BldSrc\27\305\TestResults\NightlyBuild\Client[2]\Out\ApprovalTests.dll
Company Name =
Assembly Product = ApprovalTests
--------------------
Here is the stack trace...
ApprovalTests.StackTraceParsers.StackTraceParser.Parse(StackTrace stackTrace)
ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
ApprovalTests.Approvals.<.cctor>b__11()
ApprovalTests.Approvals.GetDefaultNamer()
ApprovalTests.Approvals.Verify(IApprovalWriter writer)
ApprovalTests.Approvals.Verify(String text)
ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations[A,B,C,D,E,F,G,H,I](Func`10 processCall, String format, Func`2 resultFormatter, IEnumerable`1 aList, IEnumerable`1 bList, IEnumerable`1 cList, IEnumerable`1 dList, IEnumerable`1 eList, IEnumerable`1 fList, IEnumerable`1 gList, IEnumerable`1 hList, IEnumerable`1 iList)
ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations[A,B,C,D,E,F,G,H,I](Func`10 processCall, String format, IEnumerable`1 aList, IEnumerable`1 bList, IEnumerable`1 cList, IEnumerable`1 dList, IEnumerable`1 eList, IEnumerable`1 fList, IEnumerable`1 gList, IEnumerable`1 hList, IEnumerable`1 iList)
ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations[A,B](Func`3 processCall, IEnumerable`1 aList, IEnumerable`1 bList)
As Graham said:
"Approvals Tests infers the name the approval file by walking the stack trace to get the test method name."
Most likely, I would suggest that your compiler might be removing (inlining) the actual test method. You can prevent this by method with the annotation
[MethodImpl(MethodImplOptions.NoInlining)]
Or, and I think this is the best option, turn off the feature entirely in your compiler options (unchecking the optimize code button in project properties)
I made the following change to the project containing my test code and these errors were eliminated:
Again, I only had to make these changes to the project containing my tests.
Also, I tested the annotation suggested by Llewellyn and it worked too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With