# Create Test

> >

- **Type:** Skill
- **Install:** `agentstack add skill-anoopsg-agent-rules-create-test`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [anoopsg](https://agentstack.voostack.com/s/anoopsg)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [anoopsg](https://github.com/anoopsg)
- **Source:** https://github.com/anoopsg/agent_rules/tree/main/src/exclusive/skills/create-test

## Install

```sh
agentstack add skill-anoopsg-agent-rules-create-test
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Testing Skill

This skill defines the process for writing and running unit and widget
tests in the project.

## 1. Directory Structure

Test files must mirror the `lib/src/` directory hierarchy under `test/`:

```text
lib/src/
└── infrastructure/
    └── auth/
        └── auth_repository.dart

test/src/
└── infrastructure/
    └── auth/
        └── auth_repository_test.dart
```

All test files must end with the `_test.dart` suffix.

## 2. Mocking Guidelines

- **Mocking Tool**: Use the `mockito` package for mocking infrastructure and
  external client dependencies.
- **Generator**: Annotate test files with `@GenerateMocks` to auto-generate mocks
  using `build_runner`.

### 2.1 Generating Mocks Example

Annotate your test file's `main()` method with the dependencies to mock:

```dart
import 'package:apple_project/src/infrastructure/auth/auth_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';

// Import the generated mock file (ends with .mocks.dart)
import 'auth_repository_test.mocks.dart';

@GenerateMocks([AuthRepository])
void main() {
  // Test code goes here
}
```

To build/generate the mock implementation, run:

```bash
melos run generate
```

## 3. Writing Unit Tests

Structure tests logically using `group`, `test`, and standard Mockito APIs:

```dart
void main() {
  late MockAuthRepository mockAuthRepo;

  setUp(() {
    mockAuthRepo = MockAuthRepository();
  });

  group('AuthRepository Tests', () {
    test('login returns success on correct credentials', () async {
      // Arrange
      when(mockAuthRepo.login('user', 'pass'))
          .thenAnswer((_) async => const Ok(null));

      // Act
      final result = await mockAuthRepo.login('user', 'pass');

      // Assert
      expect(result.isOk, isTrue);
      verify(mockAuthRepo.login('user', 'pass')).called(1);
    });
  });
}
```

## 4. Running Tests

- Run all unit and widget tests:
  ```bash
  flutter test
  ```
- Run tests for a specific test file:
  ```bash
  flutter test test/src/infrastructure/auth/auth_repository_test.dart
  ```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [anoopsg](https://github.com/anoopsg)
- **Source:** [anoopsg/agent_rules](https://github.com/anoopsg/agent_rules)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-anoopsg-agent-rules-create-test
- Seller: https://agentstack.voostack.com/s/anoopsg
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
