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

Upgrading NUnit and now fully using NUnitAdapter #381

Merged
merged 5 commits into from Mar 1, 2018
Merged

Upgrading NUnit and now fully using NUnitAdapter #381

merged 5 commits into from Mar 1, 2018

Conversation

ghost
Copy link

@ghost ghost commented Feb 14, 2018

This addresses: #243

This was actually mega easy to do.

dotnet test is a first class citizen for Castle Windsor.

Please note there is a TPL test that failed for netcoreapp1.0, I will add a review flagging it so we can discuss.

@@ -26,7 +26,8 @@ namespace CastleTests

using NUnit.Framework;

[Explicit]
[Ignore("Explicit Test, this fails on dotnet core")]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly, I might raise an issue on NUnit for the adapter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a defect in the NUnit runner.

I don't know why this test is failing and wasn't being run, but it appears we don't really need it anymore as we are nearly down to no obsolete members on those interfaces and classes, so we can just get rid of the whole test.

@@ -102,6 +103,7 @@ public void Context_is_passed_onto_the_next_thread_TPL()
Assert.AreSame(instance, instanceFromOtherThread);
}
}
#endif
Copy link
Author

@ghost ghost Feb 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed for netcoreapp1.0. I am not sure why yet. I will investigate this a little more before we merge this PR. If you have any insights here I am open to suggestions. A cursory and glossy investigation is telling me this should pass. There might be a gremlin here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the conditional compilation so the pull request fails and I can see the error, or just paste the exception here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the full failure:

Failed   Context_is_passed_onto_the_next_thread_TPL
Error Message:
 System.AggregateException : One or more errors occurred. (  Expected: not equal to 6
  But was:  6
)
  ----> NUnit.Framework.AssertionException :   Expected: not equal to 6
  But was:  6

Stack Trace:
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at CastleTests.Lifestyle.ScopedLifestyleExplicitAndMultipleThreadsTestCase.Context_is_passed_onto_the_next_thread_TPL() in C:\code\Windsor\src\Castle.Windsor.Tests\Lifestyle\ScopedLifestyleExplicitAndMultipleThreadsTestCase.cs:line 102
--AssertionException
   at NUnit.Framework.Assert.ReportFailure(String message)
   at NUnit.Framework.Assert.AreNotEqual(Object expected, Object actual)
   at CastleTests.Lifestyle.ScopedLifestyleExplicitAndMultipleThreadsTestCase.<>c__DisplayClass1_0.<Context_is_passed_onto_the_next_thread_TPL>b__0() in C:\code\Windsor\src\Castle.Windsor.Tests\Lifestyle\ScopedLifestyleExplicitAndMultipleThreadsTestCase.cs:line 99
   at System.Threading.Tasks.Task.Execute()

Looks like we are in a good place, dotnet test is a first class citizen.
@@ -26,7 +26,8 @@ namespace CastleTests

using NUnit.Framework;

[Explicit]
[Ignore("Explicit Test, this fails on dotnet core")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a defect in the NUnit runner.

I don't know why this test is failing and wasn't being run, but it appears we don't really need it anymore as we are nearly down to no obsolete members on those interfaces and classes, so we can just get rid of the whole test.

@@ -102,6 +103,7 @@ public void Context_is_passed_onto_the_next_thread_TPL()
Assert.AreSame(instance, instanceFromOtherThread);
}
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the conditional compilation so the pull request fails and I can see the error, or just paste the exception here.

Gavin van der Merwe added 2 commits February 15, 2018 19:43
…his does not hold true for net45. Threads that are eagerly shared should not be asserted against.
@@ -96,14 +95,12 @@ public void Context_is_passed_onto_the_next_thread_TPL()
var initialThreadId = Thread.CurrentThread.ManagedThreadId;
var task = Task.Factory.StartNew(() =>
{
Assert.AreNotEqual(Thread.CurrentThread.ManagedThreadId, initialThreadId);
instanceFromOtherThread = Container.Resolve<A>();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a problem on my machine where if I debugged the test it would pass. Running it normally would make it fail. This test does not have proper task error handling so it swallows the real exception. On the off chance I did notice that the managed thread id was the same for both the task and the running test. Looks like the task ran on the same thread. The assert was kicking in and then squelching the real error. If netcoreapp1.0 is optimising TPL to run on the same thread, should we be asserting against it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fir3pho3nixx I saw this the other day, I did intend to look at this a bit more before getting this merged. It seems strange that it would run on the same thread, if you put some more code before task.Wait() does it still run on the same thread?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will mess with it a bit more and report back. Curiously, notice how when I added a9f5f76 which had nothing to do with this test it passed again? I expect this is a flakey test that will only fail randomly every now and then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonorossi - This is further evidence of the flappy test which asserts on random integer.

Please see this random failure when I updated markdown docs: https://ci.appveyor.com/project/castleproject/windsor/build/0.0.350#L321

This has got to be the managed thread id assertion! :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubbish assertion, how MS optimise their threading have clearly changed in netcoreapp1.0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

@ghost ghost Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's get rid of the assert.

With regards to the WCF test that failed, I've noticed in the past if the build machine is heavily loaded you can sometimes get failing tests like that, yep flakey.

…this explicit test case to be ignored for now
@@ -20,7 +20,7 @@ namespace CastleTests

using NUnit.Framework;

[Explicit]
[Ignore("Used to be explicit but fails on netcoreapp1.0 when run with VS2017 Resharper")]
public class TestConventionsValidationTestCase : AbstractContainerTestCase
{
[Test]
Copy link
Author

@ghost ghost Feb 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ignored this because it was the only other test I found that failed only when running it VS 2017. Was explicit anyway?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

@ghost
Copy link
Author

ghost commented Feb 28, 2018

@jonorossi - I think we are good to merge here.

@jonorossi jonorossi merged commit aba6f8e into castleproject:master Mar 1, 2018
@ghost ghost deleted the upgrading-nunit branch June 22, 2018 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant