-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from skbkontur/fix-global-teardown
Fix Global TearDown
- Loading branch information
Showing
8 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
GroboContainer.NUnitExtensions.Tests/ExecutionOrder/GlobalTearDownTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.IO; | ||
using System.Reflection; | ||
|
||
using FluentAssertions; | ||
|
||
using GroboContainer.NUnitExtensions.Impl.TestContext; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace GroboContainer.NUnitExtensions.Tests.ExecutionOrder | ||
{ | ||
public static class Log | ||
{ | ||
public static void Clear() | ||
{ | ||
if (File.Exists(filename)) | ||
File.Delete(filename); | ||
} | ||
|
||
public static void Line(string line) | ||
{ | ||
File.AppendAllLines(filename, new[] {line}); | ||
} | ||
|
||
public static void Check(string[] expectedLines) | ||
{ | ||
File.ReadAllLines(filename).Should().BeEquivalentTo(expectedLines); | ||
} | ||
|
||
private static readonly string filename = TestContext.CurrentContext.TestDirectory + "/GlobalTearDown.log"; | ||
} | ||
|
||
public class AndLocalTearDown : GroboTestMethodWrapperAttribute | ||
{ | ||
public override void SetUp(string testName, IEditableGroboTestContext suiteContext, IEditableGroboTestContext methodContext) | ||
{ | ||
Log.Line("AndLocalTearDown.SetUp"); | ||
} | ||
|
||
public override void TearDown(string testName, IEditableGroboTestContext suiteContext, IEditableGroboTestContext methodContext) | ||
{ | ||
Log.Line("AndLocalTearDown.TearDown"); | ||
} | ||
} | ||
|
||
[AndLocalTearDown] | ||
public class WithGlobalTearDown : GroboTestSuiteWrapperAttribute | ||
{ | ||
public override void SetUp(string suiteName, Assembly testAssembly, IEditableGroboTestContext suiteContext) | ||
{ | ||
Log.Clear(); | ||
Log.Line("WithGlobalTearDown.SetUp"); | ||
} | ||
|
||
public override void TearDown(string suiteName, Assembly testAssembly, IEditableGroboTestContext suiteContext) | ||
{ | ||
Log.Line("WithGlobalTearDown.TearDown"); | ||
} | ||
} | ||
|
||
[GroboTestSuite("GlobalTearDown"), WithGlobalTearDown] | ||
public class GlobalTearDownTest | ||
{ | ||
[Test] | ||
public void Test() | ||
{ | ||
Log.Line("GlobalTearDownTest.Test"); | ||
} | ||
} | ||
|
||
[Explicit] | ||
public class AfterTestCheck | ||
{ | ||
[Test] | ||
public void Test() | ||
{ | ||
Log.Check(new[] | ||
{ | ||
"WithGlobalTearDown.SetUp", | ||
"AndLocalTearDown.SetUp", | ||
"GlobalTearDownTest.Test", | ||
"AndLocalTearDown.TearDown", | ||
"WithGlobalTearDown.TearDown", | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "5.0.103" | ||
"version": "5.0.301" | ||
} | ||
} |