Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions caught in AppDomain.CurrentDomain.UnhandledException differ #76

Open
PauloIntechnica opened this issue Aug 20, 2015 · 0 comments
Labels

Comments

@PauloIntechnica
Copy link

If a test class assigns AppDomain.CurrentDomain.UnhandledException in the SetUp() and then an exception is thrown in a thread:

  • In NUnit GUI the executor succeeds;
  • In VS 2015 + NUnit Test Adapter the executor crashes.

The most relevant (hopefully) parts of the
Code:

    [TestFixtureAttribute ()]
    class JMeter_DataUploader_IntegrationTests
    {
        bool _AnGlobalExceptionWasCaught;

        [SetUp ()]
        public void SetupTest ()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            _AnGlobalExceptionWasCaught = false;
        }
        private void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e)
        {
            _AnGlobalExceptionWasCaught = true;
        }

        [Test ()]
        //[Timeout (10000)]
        public void Test_ConsumerProducer_HighlyThreaded ()
        {
            // ...

            // >> Build Consumer
            DataUploader dataUploader = new DataUploader ();
            Thread consumer = new Thread (
                delegate ()
                {
                    //  (throws an Exception)
                    dataUploader.UploadData (testRunDatas, ref producerIsWorking);
                });

            // ...

            // Assertions
            Assert.IsTrue (!_AnGlobalExceptionWasCaught);
        }
    }

When I run this code in the NUnit GUI executor, it successfully reaches the Assert.IsTrue(...) and marks that test as failed at that point.

When I run this code inside VS, the test executor crashes, opens a crash report window and I see nothing relevant in the "Test Explorer".

  • NUnit installed 2.6.4 (downloaded this/last week).
  • VS 2015
  • Extension "NUnit Test Adapter" installed from Extensions Manager.
  • Assemblies being handled manually (not through NuGet) - project is referencing the newly downloaded assembly: _\NUnit 2.6.4\bin\framework\nunit.framework.dll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants