Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions prompts/csharp-mstest.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider noting MSTest.Sdk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can suggest it, but not all repos use MTP and mstest.sdk is still not nicely supported in VS because of the nuget tooling, so I would not default to it.

- Create test classes that match the classes being tested (e.g., `CalculatorTests` for `Calculator`)
- Use .NET SDK test commands: `dotnet test` for running tests

Expand All @@ -36,7 +36,7 @@ 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub isn't allowing me to add a comment on the specific line. But on line 43, there is a mention of CsvDataSource. I'm not aware of such attribute 😄
We only have DataSourceAttribute which can be set to use Csv. A sample for using Csv is https://github.com/microsoft/testfx/blob/b1edce21fa74ac0444f92355d230a498196a3382/test/IntegrationTests/MSTest.Acceptance.IntegrationTests/DataSourceTests.cs, which is a bit involved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://grep.app/search?q=%5BCsvDataSource%5D yeah that one seemed curious to me as well, does not seem to exist.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth removing it then

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah as they are outside the diff commenting isn't supported.

Let's get that fixed and then I can merge these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

- Use `[DataRow]` for inline test data
- Use `[DynamicData]` for programmatically generated test data
- Use `[TestProperty]` to add metadata to tests
Expand All @@ -50,7 +50,7 @@ Your goal is to help me write effective unit tests with MSTest, covering both st
* 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
* 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
Expand Down