0

I am trying to run my approvals tests from nUnit under TeamCity

    [assembly: FrontLoadedReporter(typeof(TeamCityReporter))]        

    [Test]
    [UseReporter(typeof(WinMergeReporter))]
    public void Test()
    {
    }

Unfortunately test fails because approvals is trying to pick up the approved file from C drive.

Test(s) failed. ApprovalTests.Core.Exceptions.ApprovalMissingException : Failed Approval: Approval File "C:\...approved.txt" Not Found.

Is there anyway I can specify right location for my approval files?

bublegumm
  • 315
  • 1
  • 3
  • 10

1 Answers1

1

It is appeared that TeamCityReporter was hiding real reason of this issue.

Here is result of local run and output of approvals test with listed solutions.

System.Exception : Could Not Detect Test Framework

Either: 1) Optimizer Inlined Test Methods

Solutions: a) Add [MethodImpl(MethodImplOptions.NoInlining)] b) Set Build->Opitmize Code to False & Build->Advanced->DebugInfo to Full

or 2) Approvals is not set up to use your test framework. It currently supports [NUnit, MsTest, MbUnit, xUnit.net, xUnit.extensions, Machine.Specifications (MSpec)]

Solution: To add one use ApprovalTests.Namers.StackTraceParsers.StackTraceParser.AddParser() method to add implementation of ApprovalTests.Namers.StackTraceParsers.IStackTraceParser with support for your testing framework. To learn how to implement one see http://blog.approvaltests.com/2012/01/creating-namers.html

It was tricky to catch because usually local run is done under Debug while deployment and tests under Release. Nevertheless I hope the question and answer will be helpful for somebody else.

bublegumm
  • 315
  • 1
  • 3
  • 10