AssemblyInitialize/Cleanup should not be executed when all tests are ignored
See original GitHub issueDescribe the bug
When all tests in the project are ignored, the AssemblyInitialize
method is not executed. The AssemblyCleanup
is always executed. I’d expect both methods to always execute or not execute. The answer to this issue suggests the AssemblyCleanup
will always execute, so I expect the same from AssemblyInitialize
(otherwise, what the cleanup method supposed to clean?)
Steps To Reproduce
Set the breakpoint in AssemblyInitialize
and AssemblyCleanup
and debug
[TestClass]
public class UnitTest1
{
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
}
[AssemblyCleanup]
public static void AssemblyCleanup()
{
}
[TestMethod, Ignore]
public void TestMethod1()
{
}
}
Expected behavior
Both AssemblyInitialize
and AssemblyCleanup
are executed
Actual behavior
Only AssemblyCleanup
is executed
Issue Analytics
- State:
- Created 6 months ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
c# - AssemblyCleanup Not being run.
If a [TestClass] inherits from a base class that is in a different assembly of the derived class, the base class [AssemblyInitialize] and...
Read more >Run VSTest tests in parallel - Azure Pipelines
This option should be used when tests within an assembly have dependencies or utilize AssemblyInitialize and AssemblyCleanup , or ...
Read more >Full MSTest support for VS9/VS8 : RSRP-272588 - YouTrack
1) The test run config file is either being ignored or the Deployment section is being ignored. ... You don't seem to support...
Read more >How To Write Automated Tests Using MsTest Framework? ...
[AssemblyInitialize] – Method with this attribute will be executed only once before executing all the tests in the whole test repo; [ ...
Read more >NUnit vs. XUnit vs. MSTest: Comparing Unit Testing ...
[Ignore], Marks a test method or test class that should not be ... execution of any tests in Test Assembly, N.A, [AssemblyInitialize], N.A....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Skipping both is even better. I see no point in initializing something that won’t be used, especially if it’s a heavy operation like creating and initializing DB, for example.
@Evangelink I can repro in these versions 2.2.10, 2.2.8, 2.2.4.