test-data-strategy
Plan comprehensive test data management including synthetic data generation, data anonymization, versioning, and environment-specific strategies.
What this skill does
# Test Data Strategy
## When to Use This Skill
Use this skill when:
- **Test Data Strategy tasks** - Working on plan comprehensive test data management including synthetic data generation, data anonymization, versioning, and environment-specific strategies
- **Planning or design** - Need guidance on Test Data Strategy approaches
- **Best practices** - Want to follow established patterns and standards
## Overview
Effective test data management ensures tests have the right data at the right time while protecting sensitive information and maintaining data quality across environments.
## Test Data Types
| Type | Source | Use Case | Privacy Risk |
|------|--------|----------|--------------|
| **Synthetic** | Generated | Unit/Integration tests | None |
| **Subset** | Production sample | Performance testing | Medium |
| **Masked** | Anonymized production | Realistic scenarios | Low |
| **Production Clone** | Full copy | Pre-prod validation | High |
| **Baseline** | Curated reference | Regression testing | Low |
## Test Data Strategy Template
```markdown
# Test Data Strategy: [Project Name]
## 1. Data Requirements
### By Test Level
| Level | Data Source | Volume | Refresh |
|-------|-------------|--------|---------|
| Unit | Synthetic | Minimal | On-demand |
| Integration | Synthetic/Subset | Moderate | Per run |
| System | Masked production | Realistic | Weekly |
| Performance | Scaled synthetic | Production-like | Per release |
### By Feature Area
| Feature | Critical Data | Volume Required | Sensitivity |
|---------|---------------|-----------------|-------------|
| Authentication | User accounts | 1000 | High |
| Payments | Transactions | 10000 | High |
| Reporting | Historical data | 1M records | Medium |
## 2. Data Generation Strategy
### Synthetic Data Tools
- **Unit Tests**: AutoFixture, Bogus
- **Integration**: TestContainers + Seed
- **Performance**: Bulk generators
### Generation Rules
| Entity | Key Fields | Generation Logic |
|--------|------------|------------------|
| User | Email | `{guid}@test.example.com` |
| Order | Amount | `Random(1, 10000)` |
| Date | Timestamp | `Random(now-1y, now)` |
## 3. Data Anonymization
### PII Fields
| Field | Original | Anonymization Method |
|-------|----------|---------------------|
| Name | John Smith | Faker generated |
| Email | [email protected] | `[email protected]` |
| Phone | 555-123-4567 | `555-xxx-xxxx` |
| SSN | 123-45-6789 | `xxx-xx-xxxx` |
| Address | 123 Main St | Faker address |
| DOB | 1985-03-15 | Shift by random days |
### Anonymization Rules
- Preserve data relationships
- Maintain referential integrity
- Keep statistical properties
- Remove unique identifiers
## 4. Environment Strategy
### Dev Environment
- Source: 100% synthetic
- Refresh: On-demand
- Volume: Minimal
### QA Environment
- Source: Masked production subset
- Refresh: Weekly
- Volume: 10% of production
### Staging Environment
- Source: Masked production clone
- Refresh: Before each release
- Volume: 100% of production
### Performance Environment
- Source: Scaled synthetic
- Refresh: Before performance runs
- Volume: 150% of production
## 5. Data Versioning
### Baseline Management
- Version baseline data sets
- Track data schema changes
- Maintain backward compatibility
- Document data dependencies
### Refresh Procedures
1. Trigger: [Manual/Scheduled/Event]
2. Source: [Production/Backup/Generator]
3. Transform: [Anonymization steps]
4. Load: [Target environment]
5. Validate: [Verification checks]
## 6. Compliance Requirements
### GDPR Compliance
- [ ] No real EU citizen data in non-prod
- [ ] Right to erasure supported
- [ ] Data minimization applied
- [ ] Consent tracking anonymized
### HIPAA Compliance
- [ ] PHI fully de-identified
- [ ] Safe Harbor method applied
- [ ] Audit logs maintained
- [ ] Access controls verified
```
## Synthetic Data Generation (.NET)
### Using Bogus
```csharp
using Bogus;
public class TestDataGenerator
{
public static Faker<Customer> CustomerFaker => new Faker<Customer>()
.RuleFor(c => c.Id, f => f.Random.Guid())
.RuleFor(c => c.FirstName, f => f.Person.FirstName)
.RuleFor(c => c.LastName, f => f.Person.LastName)
.RuleFor(c => c.Email, (f, c) => f.Internet.Email(c.FirstName, c.LastName))
.RuleFor(c => c.Phone, f => f.Phone.PhoneNumber())
.RuleFor(c => c.DateOfBirth, f => f.Date.Past(50, DateTime.Now.AddYears(-18)))
.RuleFor(c => c.Address, f => new Address
{
Street = f.Address.StreetAddress(),
City = f.Address.City(),
State = f.Address.StateAbbr(),
Zip = f.Address.ZipCode()
});
public static Faker<Order> OrderFaker(Customer customer) => new Faker<Order>()
.RuleFor(o => o.Id, f => f.Random.Guid())
.RuleFor(o => o.CustomerId, customer.Id)
.RuleFor(o => o.OrderDate, f => f.Date.Recent(30))
.RuleFor(o => o.Total, f => f.Finance.Amount(10, 1000))
.RuleFor(o => o.Status, f => f.PickRandom<OrderStatus>());
}
```
### Using AutoFixture
```csharp
using AutoFixture;
using AutoFixture.Xunit2;
public class CustomerTests
{
[Theory, AutoData]
public void CreateCustomer_WithValidData_Succeeds(Customer customer)
{
// AutoFixture generates valid Customer automatically
var result = _service.Create(customer);
Assert.True(result.IsSuccess);
}
[Theory, AutoData]
public void ProcessOrder_CalculatesCorrectTotal(
[Frozen] Customer customer,
Order order,
List<OrderItem> items)
{
// Frozen ensures customer is reused
// Order and items are auto-generated
order.Items = items;
var total = _calculator.Calculate(order);
Assert.Equal(items.Sum(i => i.Quantity * i.Price), total);
}
}
```
### Seeding Test Databases
```csharp
public class TestDatabaseSeeder
{
public static async Task SeedAsync(AppDbContext context)
{
// Clear existing data
await context.Database.ExecuteSqlRawAsync("DELETE FROM Orders");
await context.Database.ExecuteSqlRawAsync("DELETE FROM Customers");
// Generate test data
var customers = TestDataGenerator.CustomerFaker.Generate(100);
await context.Customers.AddRangeAsync(customers);
foreach (var customer in customers)
{
var orders = TestDataGenerator.OrderFaker(customer).Generate(5);
await context.Orders.AddRangeAsync(orders);
}
await context.SaveChangesAsync();
}
}
```
## Data Anonymization Techniques
| Technique | Description | Use Case |
|-----------|-------------|----------|
| **Substitution** | Replace with fake data | Names, emails |
| **Shuffling** | Rearrange within column | Salaries, dates |
| **Masking** | Partial hiding | SSN (xxx-xx-1234) |
| **Generalization** | Reduce precision | Age ranges, zip prefix |
| **Nulling** | Remove entirely | Unnecessary fields |
| **Tokenization** | Replace with token | Cross-reference needs |
| **Hashing** | One-way transform | Identifiers |
### .NET Anonymization Example
```csharp
public class DataAnonymizer
{
public Customer Anonymize(Customer source)
{
return new Customer
{
Id = source.Id, // Preserve for relationships
FirstName = _faker.Person.FirstName,
LastName = _faker.Person.LastName,
Email = $"{Guid.NewGuid():N}@test.example.com",
Phone = MaskPhone(source.Phone),
SSN = "xxx-xx-" + source.SSN.Substring(7, 4),
DateOfBirth = ShiftDate(source.DateOfBirth),
Address = new Address
{
Street = _faker.Address.StreetAddress(),
City = source.Address.City, // Preserve geography
State = source.Address.State,
Zip = source.Address.Zip.Substring(0, 3) + "00"
}
};
}
private string MaskPhone(string phone)
{
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.