diff --git a/.cspell.yaml b/.cspell.yaml index 8fdf9fa..8748f93 100644 --- a/.cspell.yaml +++ b/.cspell.yaml @@ -14,6 +14,7 @@ language: en # Project-specific technical terms and tool names words: + - antipatterns - Anson - Blockquotes - buildmark diff --git a/.github/agents/code-quality.agent.md b/.github/agents/code-quality.agent.md index 37100ee..4ce302e 100644 --- a/.github/agents/code-quality.agent.md +++ b/.github/agents/code-quality.agent.md @@ -1,7 +1,7 @@ --- name: code-quality description: Ensures code quality through comprehensive linting and static analysis. -tools: [edit, read, search, execute, github] +tools: [read, search, edit, execute, github, agent] user-invocable: true --- diff --git a/.github/agents/code-review.agent.md b/.github/agents/code-review.agent.md index 6ef6289..fb01a20 100644 --- a/.github/agents/code-review.agent.md +++ b/.github/agents/code-review.agent.md @@ -1,7 +1,7 @@ --- name: code-review description: Assists in performing formal file reviews. -tools: [read, search, github, agent, execute] +tools: [read, search, edit, execute, github, web, agent] user-invocable: true --- diff --git a/.github/agents/repo-consistency.agent.md b/.github/agents/repo-consistency.agent.md index ef5d296..b4fa45b 100644 --- a/.github/agents/repo-consistency.agent.md +++ b/.github/agents/repo-consistency.agent.md @@ -1,7 +1,7 @@ --- name: repo-consistency description: Ensures downstream repositories remain consistent with the TemplateDotNetLibrary template patterns and best practices. -tools: [edit, read, search, github, agent] +tools: [read, search, edit, execute, github, agent] user-invocable: true --- @@ -18,7 +18,7 @@ consistency gaps, template evolution updates, and recommended changes for the sp ## Consistency Steps -1. Fetch the last 20 merged PRs (`is:pr is:merged`) from +1. Fetch the 20 most recently merged PRs (`is:pr is:merged sort:updated-desc`) from 2. Determine the intent of the template pull requests (what changes were performed to which files) 3. Apply missing changes to this repository's files (if appropriate and with translation) diff --git a/.github/agents/requirements.agent.md b/.github/agents/requirements.agent.md index 8d7cc56..3e41722 100644 --- a/.github/agents/requirements.agent.md +++ b/.github/agents/requirements.agent.md @@ -1,7 +1,7 @@ --- name: requirements description: Develops requirements and ensures appropriate test coverage. -tools: [edit, read, search, execute] +tools: [read, search, edit, execute, github, web, agent] user-invocable: true --- diff --git a/.github/agents/software-developer.agent.md b/.github/agents/software-developer.agent.md index ceed8d4..7c46ec9 100644 --- a/.github/agents/software-developer.agent.md +++ b/.github/agents/software-developer.agent.md @@ -1,7 +1,7 @@ --- name: software-developer description: Writes production code and self-validation tests. -tools: [edit, read, search, execute, github] +tools: [read, search, edit, execute, github, agent] user-invocable: true --- diff --git a/.github/agents/technical-writer.agent.md b/.github/agents/technical-writer.agent.md index fa95e6c..b0801fc 100644 --- a/.github/agents/technical-writer.agent.md +++ b/.github/agents/technical-writer.agent.md @@ -1,7 +1,7 @@ --- name: technical-writer description: Ensures documentation is accurate and complete. -tools: [edit, read, search, execute] +tools: [read, search, edit, execute, github, agent] user-invocable: true --- diff --git a/.github/agents/test-developer.agent.md b/.github/agents/test-developer.agent.md index 4e6130e..d8bd877 100644 --- a/.github/agents/test-developer.agent.md +++ b/.github/agents/test-developer.agent.md @@ -1,7 +1,7 @@ --- name: test-developer description: Writes unit and integration tests. -tools: [edit, read, search, execute] +tools: [read, search, edit, execute, github, agent] user-invocable: true --- diff --git a/AGENTS.md b/AGENTS.md index 544e37b..0690531 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -177,6 +177,93 @@ This repository follows continuous compliance practices from DEMA Consulting Con For detailed requirements format, test linkage patterns, and ReqStream integration, call the @requirements agent. +## MSTest Best Practices + +When writing or reviewing tests, follow these MSTest V4 best practices to avoid common antipatterns. + +### Antipatterns to Avoid + +#### MSTEST0058 — Assertions in Catch Blocks + +Do not place assertions in catch blocks. Use `Assert.ThrowsExactly()` instead: + +```csharp +// ❌ Bad: Assertion in catch block +try +{ + SomeMethod(); + Assert.Fail("Expected exception"); +} +catch (InvalidOperationException) +{ + // passes silently +} + +// ✅ Good: Use Assert.ThrowsExactly +Assert.ThrowsExactly(() => SomeMethod()); +``` + +#### Prefer Specific Assertions Over Assert.IsTrue/IsFalse + +Using `Assert.IsTrue`/`Assert.IsFalse` for equality checks produces poor failure messages. Use specific assertions: + +```csharp +// ❌ Bad: Poor failure message +Assert.IsTrue(result == 42); +Assert.IsFalse(result != 42); + +// ✅ Good: Rich failure message with expected/actual values +Assert.AreEqual(42, result); +Assert.AreNotEqual(0, result); +``` + +#### Use Assert.HasCount for Collections + +Do not use `Assert.IsTrue` for collection count checks: + +```csharp +// ❌ Bad: Poor failure message +Assert.IsTrue(collection.Count == 3); + +// ✅ Good: Rich failure message +Assert.HasCount(3, collection); +``` + +#### Use Assert.StartsWith for Prefix Checks + +Do not use `Assert.IsTrue(value.StartsWith(...))` — use the dedicated assertion: + +```csharp +// ❌ Bad: Poor failure message +Assert.IsTrue(value.StartsWith("prefix")); + +// ✅ Good: Rich failure message showing expected prefix and actual value +Assert.StartsWith("prefix", value); +``` + +#### Non-Public Test Classes and Methods Are Silently Ignored + +MSTest silently ignores non-public test classes and test methods — no warning or error is produced: + +```csharp +// ❌ Bad: Silently ignored by the test runner +class MyTests // missing public modifier +{ + [TestMethod] + void TestSomething() // missing public modifier + { } +} + +// ✅ Good: Properly visible to the test runner +[TestClass] +public class MyTests +{ + [TestMethod] + public void TestSomething() + { } +} +``` + ## Agent Report Files When agents need to write report files to communicate with each other or the user, follow these guidelines: diff --git a/README.md b/README.md index b301ffa..26ecfb1 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,8 @@ We welcome contributions! Please see our [Contributing Guide][contributing] for This project is licensed under the MIT License - see the [LICENSE][link-license] file for details. +By contributing to this project, you agree that your contributions will be licensed under the MIT License. + ## Support - 📝 [Report a Bug](https://github.com/demaconsulting/TestResults/issues/new?labels=bug) diff --git a/docs/reqstream/ots-pandoctool.yaml b/docs/reqstream/ots-pandoctool.yaml index da9aec2..551beb0 100644 --- a/docs/reqstream/ots-pandoctool.yaml +++ b/docs/reqstream/ots-pandoctool.yaml @@ -10,8 +10,8 @@ sections: - title: OTS Software Requirements sections: + # TODO: Add requirement when demaconsulting.pandoctool supports --validate - title: PandocTool Requirements - # TODO: Add requirement when demaconsulting.pandoctool supports --validate # requirements: # - id: TestResults-OTS-PandocTool # title: PandocTool shall convert markdown documentation to HTML for PDF generation. diff --git a/docs/reqstream/ots-sonarscanner.yaml b/docs/reqstream/ots-sonarscanner.yaml index 422ba97..271547e 100644 --- a/docs/reqstream/ots-sonarscanner.yaml +++ b/docs/reqstream/ots-sonarscanner.yaml @@ -10,8 +10,8 @@ sections: - title: OTS Software Requirements sections: + # TODO: Add requirement when dotnet-sonarscanner supports --validate - title: SonarScanner Requirements - # TODO: Add requirement when dotnet-sonarscanner supports --validate # requirements: # - id: TestResults-OTS-SonarScanner # title: SonarScanner shall upload code analysis results to SonarCloud. diff --git a/docs/reqstream/ots-weasyprinttool.yaml b/docs/reqstream/ots-weasyprinttool.yaml index f053b9b..bfc104b 100644 --- a/docs/reqstream/ots-weasyprinttool.yaml +++ b/docs/reqstream/ots-weasyprinttool.yaml @@ -10,8 +10,8 @@ sections: - title: OTS Software Requirements sections: + # TODO: Add requirement when demaconsulting.weasyprinttool supports --validate - title: WeasyPrintTool Requirements - # TODO: Add requirement when demaconsulting.weasyprinttool supports --validate # requirements: # - id: TestResults-OTS-WeasyPrintTool # title: WeasyPrintTool shall convert HTML documentation to PDF release artifacts.