Skip to content

Commit e29a3f0

Browse files
Fix CLI test warnings (#1450)
## Why make this change? - Some unit Tests were complaining about wrong Signature of the Class Initialization Test Setup method, due to which they were not getting discovered. ## What is this change? - When declaring ClassInitialize attribute on a method, the method has to be static, public, void and should take a single parameter of type TestContext. - I added a parameter of type TestContext to fix. - Performance Improvement by using ClassInitialize than TestInitialize. ## How was this tested? - [x] Passing existing Unit Tests - [x] No warnings
1 parent 75ee9df commit e29a3f0

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

src/Cli.Tests/AddEntityTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class AddEntityTests
1212
/// <summary>
1313
/// Setup the logger for CLI
1414
/// </summary>
15-
[TestInitialize]
16-
public void SetupLoggerForCLI()
15+
[ClassInitialize]
16+
public static void SetupLoggerForCLI(TestContext context)
1717
{
1818
TestHelper.SetupTestLoggerForCLI();
1919
}

src/Cli.Tests/EndToEndTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class EndToEndTests
1313
/// Setup the logger and test file for CLI
1414
/// </summary>
1515
[ClassInitialize]
16-
public static void Setup()
16+
public static void Setup(TestContext context)
1717
{
1818
if (!File.Exists(TEST_SCHEMA_FILE))
1919
{

src/Cli.Tests/InitTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class InitTests
1515
/// Setup the logger and test file for CLI
1616
/// </summary>
1717
[ClassInitialize]
18-
public static void Setup()
18+
public static void Setup(TestContext context)
1919
{
2020
if (!File.Exists(TEST_SCHEMA_FILE))
2121
{

src/Cli.Tests/UpdateEntityTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class UpdateEntityTests
1212
/// <summary>
1313
/// Setup the logger for CLI
1414
/// </summary>
15-
[TestInitialize]
16-
public void SetupLoggerForCLI()
15+
[ClassInitialize]
16+
public static void SetupLoggerForCLI(TestContext context)
1717
{
1818
TestHelper.SetupTestLoggerForCLI();
1919
}

src/Cli.Tests/UtilsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class UtilsTests
1212
/// <summary>
1313
/// Setup the logger for CLI
1414
/// </summary>
15-
[TestInitialize]
16-
public void SetupLoggerForCLI()
15+
[ClassInitialize]
16+
public static void SetupLoggerForCLI(TestContext context)
1717
{
1818
Mock<ILogger<Utils>> utilsLogger = new();
1919
Utils.SetCliUtilsLogger(utilsLogger.Object);

0 commit comments

Comments
 (0)