-
Notifications
You must be signed in to change notification settings - Fork 458
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
Conversation
@@ -26,7 +26,8 @@ namespace CastleTests | |||
|
|||
using NUnit.Framework; | |||
|
|||
[Explicit] | |||
[Ignore("Explicit Test, this fails on dotnet core")] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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")] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
…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>(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonorossi ^^
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jesus christ! Another flappy test.
https://ci.appveyor.com/project/castleproject/windsor/build/0.0.352#L736
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
@jonorossi - I think we are good to merge here. |
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.