Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes the message "Approvals is not set up to use your test framework."?

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:


Test method Test_CanvasModeConverters threw exception:
System.Exception: Approvals is not set up to use your test framework.
It currently supports [NUnit, MsTest, MbUnit, xUnit.net] To add one use ApprovalTests.StackTraceParsers.StackTraceParser.AddParser() method to add implementation of ApprovalTests.StackTraceParsers.IStackTraceParser with support for your testing framework. To learn how to implement one see http://blog.approvaltests.com/2012/01/creating-namers.html

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)
like image 477
user2015036 Avatar asked Dec 21 '22 10:12

user2015036


2 Answers

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)

like image 78
llewellyn falco Avatar answered Apr 29 '23 03:04

llewellyn falco


I made the following change to the project containing my test code and these errors were eliminated:

  1. Disable Code Optimization as suggested by Llewellyn
  2. In Advanced Build Settings, set "Debug Info" to "Full". It was set to pdb-only for Release builds in my project.

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.

like image 31
jerryo Avatar answered Apr 29 '23 01:04

jerryo