Update csharp-mstest.prompt.md (#43)
* Update csharp-mstest.prompt.md Update to align with our current recommendations on how to use MSTest. * remove csvDataSource, fix list style
This commit is contained in:
parent
1ba5cc78ff
commit
064bbfe7eb
@ -11,7 +11,7 @@ Your goal is to help me write effective unit tests with MSTest, covering both st
|
||||
## Project Setup
|
||||
|
||||
- Use a separate test project with naming convention `[ProjectName].Tests`
|
||||
- Reference Microsoft.NET.Test.Sdk, MSTest.TestAdapter, and MSTest.TestFramework packages
|
||||
- Reference MSTest package
|
||||
- Create test classes that match the classes being tested (e.g., `CalculatorTests` for `Calculator`)
|
||||
- Use .NET SDK test commands: `dotnet test` for running tests
|
||||
|
||||
@ -36,33 +36,32 @@ Your goal is to help me write effective unit tests with MSTest, covering both st
|
||||
|
||||
## Data-Driven Tests
|
||||
|
||||
- Use `[DataTestMethod]` combined with data source attributes
|
||||
- Use `[TestMethod]` combined with data source attributes
|
||||
- Use `[DataRow]` for inline test data
|
||||
- Use `[DynamicData]` for programmatically generated test data
|
||||
- Use `[TestProperty]` to add metadata to tests
|
||||
- Consider `[CsvDataSource]` for external data sources
|
||||
- Use meaningful parameter names in data-driven tests
|
||||
|
||||
## Assertions
|
||||
|
||||
* Use `Assert.AreEqual` for value equality
|
||||
* Use `Assert.AreSame` for reference equality
|
||||
* Use `Assert.IsTrue`/`Assert.IsFalse` for boolean conditions
|
||||
* Use `CollectionAssert` for collection comparisons
|
||||
* Use `StringAssert` for string-specific assertions
|
||||
* Use `Assert.ThrowsException<T>` to test exceptions
|
||||
* Ensure assertions are simple in nature and have a message provided for clarity on failure
|
||||
- Use `Assert.AreEqual` for value equality
|
||||
- Use `Assert.AreSame` for reference equality
|
||||
- Use `Assert.IsTrue`/`Assert.IsFalse` for boolean conditions
|
||||
- Use `CollectionAssert` for collection comparisons
|
||||
- Use `StringAssert` for string-specific assertions
|
||||
- Use `Assert.Throws<T>` to test exceptions
|
||||
- Ensure assertions are simple in nature and have a message provided for clarity on failure
|
||||
|
||||
## Mocking and Isolation
|
||||
|
||||
* Consider using Moq or NSubstitute alongside MSTest
|
||||
* Mock dependencies to isolate units under test
|
||||
* Use interfaces to facilitate mocking
|
||||
* Consider using a DI container for complex test setups
|
||||
- Consider using Moq or NSubstitute alongside MSTest
|
||||
- Mock dependencies to isolate units under test
|
||||
- Use interfaces to facilitate mocking
|
||||
- Consider using a DI container for complex test setups
|
||||
|
||||
## Test Organization
|
||||
|
||||
* Group tests by feature or component
|
||||
* Use test categories with `[TestCategory("Category")]`
|
||||
* Use test priorities with `[Priority(1)]` for critical tests
|
||||
* Use `[Owner("DeveloperName")]` to indicate ownership
|
||||
- Group tests by feature or component
|
||||
- Use test categories with `[TestCategory("Category")]`
|
||||
- Use test priorities with `[Priority(1)]` for critical tests
|
||||
- Use `[Owner("DeveloperName")]` to indicate ownership
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user