Skip to content
This repository has been archived by the owner on Oct 16, 2018. It is now read-only.

No test failure information when test fails and test class Dispose also fails #38

Closed
mrward opened this issue Jul 22, 2016 · 1 comment
Labels

Comments

@mrward
Copy link
Contributor

mrward commented Jul 22, 2016

When a test throws an exception and the test class has a Dispose method that also fails there is no error information reported. The Tests Results window shows 0 tests have run.

To repro:

  1. Create a new xunit project.
  2. Add the test class as shown below:
using System;
using System.IO;
using Xunit;

namespace xunittest
{
    public class MyTest : IDisposable
    {
        public void Dispose ()
        {
            File.Delete ("/unknown/file.txt");
        }

        [Fact]
        public void Foo ()
        {
            throw new Exception ();
        }
    }
}
  1. Build and run the tests.

Expected result:

Error information is available in Test Results window. If that is not possible then showing the output from xunit in a console pad would be help diagnose the error.

Actual result:

No errors are shown.
0 tests shown as run in the Tests Results window.
Unit tests windows shows test as not run.

If I run xunit from the command line I see the failure.

 mono ~/Downloads/xunit.runner.console.2.1.0/tools/xunit.console.exe bin/Debug/xunit-test.dll
xUnit.net Console Runner (32-bit .NET 4.0.30319.42000)
  Discovering: xunit-test
  Discovered:  xunit-test
  Starting:    xunit-test
    xunit-test.MyTest.Foo [FAIL]
      System.AggregateException : One or more errors occurred.
      ---- System.Exception : Exception of type 'System.Exception' was thrown.
      ---- System.IO.DirectoryNotFoundException : Could not find a part of the path "/unknown/file.txt".
      Stack Trace:

        ----- Inner Stack Trace #1 (System.Exception) -----
          at xunit-test.MyTest.Foo () <0x2ff8e60 + 0x0001f> in <filename unknown>:0 
          at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
          at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x2ff8c70 + 0x00093> in <filename unknown>:0 
        ----- Inner Stack Trace #2 (System.IO.DirectoryNotFoundException) -----
          at System.IO.File.Delete (System.String path) <0x2ffbfd8 + 0x00103> in <filename unknown>:0 
          at xunit-test.MyTest.Dispose () <0x2ffbfb0 + 0x00013> in <filename unknown>:0 
          at ReflectionAbstractionExtensions.DisposeTestClass (ITest test, System.Object testClass, IMessageBus messageBus, Xunit.Sdk.ExecutionTimer timer, System.Threading.CancellationTokenSource cancellationTokenSource) <0x2ffbd40 + 0x00157> in <filename unknown>:0 
  Finished:    xunit-test
=== TEST EXECUTION SUMMARY ===
   xunit-test  Total: 1, Errors: 0, Failed: 1, Skipped: 0, Time: 0.101s
@lextm
Copy link
Collaborator

lextm commented Sep 29, 2017

Finally it turned out to be a MonoDevelop issue. I quickly patched it here for this extension in 0.7.12 and would report back to Xamarin Bugzilla.

Fixed in 155f34a.

The actual culprit that prevents this extension from showing the issue comes from two places.

First, the MonoDevelop code leads to a runner crash,

 Traceback (most recent call last):
1
at System.IO.BinaryWriter.Write(System.String value) in "/private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/io/binarywriter.cs" line 420
2
at MonoDevelop.Core.Execution.BinaryMessage.WriteArray(System.IO.BinaryWriter bw, System.Object val) in "MonoDevelop.Core.Execution.BinaryMessage" line 567
3
at MonoDevelop.Core.Execution.BinaryMessage.WriteValue(System.IO.BinaryWriter bw, System.Object val) in "MonoDevelop.Core.Execution.BinaryMessage" line 44
4
at MonoDevelop.Core.Execution.BinaryMessage.Write(System.IO.Stream outStream) in "MonoDevelop.Core.Execution.BinaryMessage" line 146
5
at MonoDevelop.Core.Execution.RemoteProcessServer.WriteMessage(System.Byte type, MonoDevelop.Core.Execution.BinaryMessage msg) in "MonoDevelop.Core.Execution.RemoteProcessServer" line 119
System.ArgumentNullException: Value cannot be null.
Parameter name: value

So no information is reported back to the extension itself.

Second, the extension code does not handle AggregateException very well (under EASY_DEBUGGING mode).

Both have been fixed now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants