Skip to content

Commit 3549289

Browse files
committed
Migrate all tests to be an integration tests
1 parent 54bcb9d commit 3549289

33 files changed

+373
-1696
lines changed

CONTRIBUTING.md

Lines changed: 21 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ SharpAssert/
2929
│ ├── SharpAssert.Runtime/ # Core assertion library with Assert methods
3030
│ ├── SharpAssert/ # MSBuild source rewriter + main package
3131
│ ├── SharpAssert.Tests/ # Unit tests for runtime and rewriter
32-
│ ├── SharpAssert.IntegrationTests/ # ★ Integration tests (MSBuild task)
3332
│ ├── SharpAssert.PackageTest/ # Package tests (local NuGet feed)
3433
│ ├── SharpAssert.PowerAssertTest/ # PowerAssert forced mode tests
3534
│ └── SharpAssert.Demo/ # Demo project showcasing features
@@ -48,31 +47,22 @@ SharpAssert/
4847

4948
## 🧪 Testing Strategy
5049

51-
SharpAssert uses a comprehensive **four-layer testing approach** to ensure reliability and maintainability across all development phases.
52-
53-
> **For architectural details and implementation rationale, see [prd.md](prd.md) Section 9: Four-Layer Testing Strategy.**
50+
SharpAssert uses a comprehensive **three-layer testing approach** to ensure reliability and maintainability across all development phases.
5451

5552
### 1. **Unit Tests** - Component-Level Validation
5653
- **SharpAssert.Tests** - Tests core assertion logic and rewriter components
5754
- **Purpose**: Fast feedback during development, tests individual methods and classes
5855
- **Run with**: `dotnet test src/SharpAssert.Tests/`
5956

60-
### 2. **Integration Tests** - MSBuild Task Validation (New!)
61-
- **SharpAssert.IntegrationTests** - Tests the rewriter as an actual MSBuild task during development
62-
- **Purpose**: Validates that MSBuild integration works without requiring NuGet packages
63-
- **Key Innovation**: Uses project references with `ReferenceOutputAssembly="false"` and direct import of `.targets` files
64-
- **MSBuild Task Testing**: Overrides `SharpAssertRewriterPath` to use local build output
65-
- **Run with**: `dotnet test src/SharpAssert.IntegrationTests/`
66-
67-
### 3. **Package Tests** - End-to-End NuGet Validation
57+
### 2. **Package Tests** - End-to-End NuGet Validation
6858
- **SharpAssert.PackageTest** - Tests basic functionality via NuGet packages
69-
- **SharpAssert.PowerAssertTest** - Tests PowerAssert forced mode via NuGet packages
59+
- **SharpAssert.PowerAssertTest** - Tests PowerAssert forced mode via NuGet packages
7060
- **Purpose**: Validates complete end-user experience including packaging and MSBuild integration
7161
- **Isolation**: Uses separate solution (`SharpAssert.PackageTesting.sln`) and NuGet config
7262
- **Run with**: `./test-local.sh`
7363

74-
### 4. **Development Scripts** - Automated Workflows
75-
- **`./dev-test.sh`** - Fast development testing (Unit + Integration only)
64+
### 3. **Development Scripts** - Automated Workflows
65+
- **`./dev-test.sh`** - Fast development testing (Unit tests only)
7666
- **`./test-local.sh`** - Complete package validation with cache isolation
7767

7868
### Testing Architecture Overview
@@ -83,7 +73,6 @@ SharpAssert uses a comprehensive **four-layer testing approach** to ensure relia
8373
├─────────────────────────────────────────────────────────────┤
8474
│ SharpAssert.sln (Main Solution) │
8575
│ ├── SharpAssert.Tests (unit tests) │
86-
│ ├── SharpAssert.IntegrationTests (MSBuild task tests) ★ │
8776
│ ├── SharpAssert.Demo (feature showcase) │
8877
│ └── ... (main projects) │
8978
├─────────────────────────────────────────────────────────────┤
@@ -93,28 +82,6 @@ SharpAssert uses a comprehensive **four-layer testing approach** to ensure relia
9382
└─────────────────────────────────────────────────────────────┘
9483
```
9584

96-
### Integration Tests: MSBuild Task Testing Innovation
97-
98-
The **SharpAssert.IntegrationTests** project enables testing the MSBuild rewriter during development without packaging:
99-
100-
```xml
101-
<!-- Project reference for build dependency only -->
102-
<ProjectReference Include="..\SharpAssert\SharpAssert.csproj"
103-
ReferenceOutputAssembly="false" />
104-
105-
<!-- Direct import of targets file (simulates NuGet package behavior) -->
106-
<Import Project="..\SharpAssert\build\SharpAssert.targets" />
107-
108-
<!-- Override rewriter path to use local build output -->
109-
<SharpAssertRewriterPath>$(MSBuildThisFileDirectory)..\SharpAssert\bin\$(Configuration)\net9.0\SharpAssert.dll</SharpAssertRewriterPath>
110-
```
111-
112-
This approach:
113-
- ✅ Tests MSBuild task functionality during development
114-
- ✅ Eliminates need to package for every rewriter change
115-
- ✅ Provides fast feedback loop for MSBuild integration issues
116-
- ✅ Simulates real NuGet package behavior without packaging overhead
117-
11885
### Package Testing Isolation
11986

12087
Package tests use complete isolation to prevent global NuGet cache pollution:
@@ -127,23 +94,21 @@ Package tests use complete isolation to prevent global NuGet cache pollution:
12794
### Testing Workflow by Development Phase
12895

12996
```bash
130-
# ⚡ Fast development (Unit + Integration) - No packaging required
97+
# ⚡ Fast development (Unit tests) - No packaging required
13198
./dev-test.sh
13299

133100
# 📦 Full validation before commits (includes package tests)
134101
./test-local.sh
135102

136103
# 🔧 Manual testing workflows
137-
dotnet test # All tests in main solution
138-
dotnet test src/SharpAssert.IntegrationTests/ # Just MSBuild integration tests
139-
./publish-local.sh # Build packages to local feed
140-
dotnet test SharpAssert.PackageTesting.sln # Just package tests
104+
dotnet test # All tests in main solution
105+
./publish-local.sh # Build packages to local feed
106+
dotnet test SharpAssert.PackageTesting.sln # Just package tests
141107
```
142108

143109
### When to Use Each Test Layer
144110

145111
- **Unit Tests**: Fast development, testing individual methods/classes
146-
- **Integration Tests**: Validating MSBuild task behavior, rewriter integration
147112
- **Package Tests**: Before commits, validating end-user experience
148113
- **Development Scripts**: Daily workflow automation
149114

@@ -242,43 +207,24 @@ This serves as the **automated Clean Install Test** ensuring packaging works cor
242207

243208
### Rewriter Development
244209

245-
Working on the MSBuild rewriter now has **two validation approaches**:
210+
Working on the MSBuild rewriter:
246211

247-
#### Fast Development Cycle (Recommended)
248-
249-
1. **Use Integration Tests for rapid iteration**
212+
1. **Write unit tests** in `SharpAssert.Tests/Rewriter/` for fast feedback
250213
```bash
251-
# Fast feedback - no packaging required
252-
dotnet test src/SharpAssert.IntegrationTests/
253-
# or use the dev script
254-
./dev-test.sh
214+
dotnet test src/SharpAssert.Tests/ --filter "FullyQualifiedName~Rewriter"
255215
```
256216

257-
2. **Debug integration tests**
258-
- Set breakpoints in `SharpLambdaRewriteTask` or `SharpAssertRewriter`
259-
- Integration tests use your local build output directly
260-
- Inspect rewritten files in: `src/SharpAssert.IntegrationTests/obj/Debug/net9.0/SharpRewritten/`
261-
262-
#### Complete Package Validation
263-
264-
1. **Use Package Tests for final validation**
217+
2. **Use package tests for validation**
265218
```bash
266-
# Complete end-to-end validation (slower)
219+
# Complete end-to-end validation
267220
./test-local.sh
268221
```
269222

270-
2. **Debug package tests**
223+
3. **Debug package tests**
271224
- Inspect rewritten code in: `src/SharpAssert.PackageTest/obj/Debug/net9.0/SharpRewritten/`
272225
- Use verbose MSBuild logging: `dotnet build -v diagnostic`
273226
- Check #line directives in generated files
274227

275-
#### Integration Test Benefits for Rewriter Development
276-
277-
-**No packaging step** - directly uses your build output
278-
- 🔄 **Fast feedback loop** - change code, run test immediately
279-
- 🎯 **MSBuild task testing** - validates actual MSBuild integration
280-
- 🔧 **Easy debugging** - breakpoints work seamlessly
281-
282228
### Demo Project
283229

284230
The **SharpAssert.Demo** project provides a living documentation system for exploring and showcasing features:
@@ -308,21 +254,13 @@ See [SharpAssert.Demo/README.md](src/SharpAssert.Demo/README.md) for full docume
308254
1. **Write failing test first** (TDD)
309255
2. **Implement minimal code** to pass the test
310256
3. **Refactor** if needed
311-
4. **Update integration tests** if behavior changes
312-
5. **Test the package** with `./test-local.sh`
313-
6. **Update documentation** if adding public API
257+
4. **Test the package** with `./test-local.sh`
258+
5. **Update documentation** if adding public API
314259

315260
## 🐛 Debugging Issues
316261

317262
### Common Problems by Test Layer
318263

319-
**Integration Tests (SharpAssert.IntegrationTests) - MSBuild Task Issues:**
320-
- Verify the rewriter project builds successfully: `dotnet build SharpAssert/`
321-
- Check that `SharpAssertRewriterPath` points to correct assembly location
322-
- Ensure `.targets` file is properly imported
323-
- Look for rewritten files in `src/SharpAssert.IntegrationTests/obj/Debug/net9.0/SharpRewritten/`
324-
- Use `dotnet build src/SharpAssert.IntegrationTests/ -v diagnostic` for detailed MSBuild logging
325-
326264
**Package Tests - End-to-End Issues:**
327265
- **Rewriter not working**: Check `SharpAssert` package is installed (SharpAssert.Runtime comes automatically)
328266
- **Package test fails**: Clean local feed `rm -rf local-feed` then `./publish-local.sh`
@@ -343,7 +281,7 @@ See [SharpAssert.Demo/README.md](src/SharpAssert.Demo/README.md) for full docume
343281

344282
### Debugging Workflow
345283

346-
1. **Start with Integration Tests** - fastest feedback for MSBuild issues
284+
1. **Start with Unit Tests** - fastest feedback for logic issues
347285
2. **Use Package Tests** for complete validation - slower but comprehensive
348286
3. **Check both solutions** - main solution vs package testing solution
349287
4. **Clean and rebuild** when in doubt - `dotnet clean && dotnet build`
@@ -404,14 +342,12 @@ Follow [Semantic Versioning](https://semver.org/):
404342
### Testing Best Practices
405343

406344
1. **Use the right test layer for the job**:
407-
- **Unit tests** for business logic and algorithms
408-
- **Integration tests** for MSBuild task behavior and rewriter validation
345+
- **Unit tests** for business logic, algorithms, and rewriter components
409346
- **Package tests** for complete end-to-end scenarios
410347

411348
2. **Follow the development testing workflow**:
412349
- Start with `./dev-test.sh` for rapid iteration
413350
- Use `./test-local.sh` before committing for full validation
414-
- Run integration tests when changing rewriter logic
415351

416352
3. **Always run tests** before committing - use `./test-local.sh` for complete validation
417353

@@ -425,8 +361,8 @@ Follow [Semantic Versioning](https://semver.org/):
425361

426362
### MSBuild Rewriter Best Practices
427363

428-
1. **Start with integration tests** when developing rewriter features
429-
2. **Test MSBuild integration early** - don't wait for packaging to catch integration issues
364+
1. **Start with unit tests** when developing rewriter features
365+
2. **Test with package tests** before committing changes
430366
3. **Use isolated package testing** to prevent global cache pollution
431367
4. **Verify generated code quality** - check the rewritten files in `obj/` directories
432368

SharpAssert.sln

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpAssert.PackageTest", "
1010
EndProject
1111
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpAssert.PowerAssertTest", "src\SharpAssert.PowerAssertTest\SharpAssert.PowerAssertTest.csproj", "{D6D87294-D61C-47CF-9FA6-8F1619140466}"
1212
EndProject
13-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpAssert.IntegrationTests", "src\SharpAssert.IntegrationTests\SharpAssert.IntegrationTests.csproj", "{64391C1B-BDA7-4E82-9059-41AE07792FE4}"
14-
EndProject
1513
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
1614
EndProject
1715
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpAssert.Demo", "src\SharpAssert.Demo\SharpAssert.Demo.csproj", "{37E60194-2FE9-408E-B23E-CDB5199ABE36}"
@@ -82,18 +80,6 @@ Global
8280
{D6D87294-D61C-47CF-9FA6-8F1619140466}.Release|x64.Build.0 = Release|Any CPU
8381
{D6D87294-D61C-47CF-9FA6-8F1619140466}.Release|x86.ActiveCfg = Release|Any CPU
8482
{D6D87294-D61C-47CF-9FA6-8F1619140466}.Release|x86.Build.0 = Release|Any CPU
85-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
86-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
87-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Debug|x64.ActiveCfg = Debug|Any CPU
88-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Debug|x64.Build.0 = Debug|Any CPU
89-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Debug|x86.ActiveCfg = Debug|Any CPU
90-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Debug|x86.Build.0 = Debug|Any CPU
91-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
92-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Release|Any CPU.Build.0 = Release|Any CPU
93-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Release|x64.ActiveCfg = Release|Any CPU
94-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Release|x64.Build.0 = Release|Any CPU
95-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Release|x86.ActiveCfg = Release|Any CPU
96-
{64391C1B-BDA7-4E82-9059-41AE07792FE4}.Release|x86.Build.0 = Release|Any CPU
9783
{37E60194-2FE9-408E-B23E-CDB5199ABE36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
9884
{37E60194-2FE9-408E-B23E-CDB5199ABE36}.Debug|Any CPU.Build.0 = Debug|Any CPU
9985
{37E60194-2FE9-408E-B23E-CDB5199ABE36}.Debug|x64.ActiveCfg = Debug|Any CPU

0 commit comments

Comments
 (0)