Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Fix Released
|
High
|
Charlie Poole | ||
NUnit V2 |
Fix Released
|
High
|
Charlie Poole |
Bug Description
If I run the tests below in the NUnit GUI 2.5.2, both tests pass. If I run them in the 2.5.3 GUI, the second test to run fails.
I think this is related to the code change here, http://
I think the changed behaviour happens because in the TestContext class, the constructor uses the static field "current" as being the context that existed at the beginning of running the test. But the static field gets set before the identity changes in TFSU, so when it's used at the TestMethod level, even though Thread.
This report originated from a thread on the NUnit-discuss group here, http://
using System.
using System.Threading;
using NUnit.Framework;
namespace ThreadStateTest
{
[TestFixture]
public class ThreadIdentityTest2
{
public void TestFixtureSetUp()
{
var identity = new GenericIdentity
}
[Test]
public void Test1()
{
}
[Test]
public void Test2()
{
}
}
}
Changed in nunitv2: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
status: | Triaged → In Progress |
Changed in nunitv2: | |
status: | In Progress → Fix Committed |
Changed in nunitv2: | |
status: | Fix Committed → Fix Released |
Changed in nunit-3.0: | |
milestone: | 2.9.4 → none |
tags: | added: v2port |
Changed in nunit-3.0: | |
status: | Triaged → Fix Committed |
milestone: | none → 2.9.5 |
Changed in nunit-3.0: | |
status: | Fix Committed → Fix Released |
I think NUnit needs to set the CurrentPrincipal for each thread from the TestContext upon creating it. This affects several different locations in NUnit, so we should try to encapsulate it.