Unit test writer
Skill AtulPurohit/Antigravity-Awesome-Skills/skills/unit-test-writer
Write comprehensive unit tests that verify behavior, catch regressions, and document intent. Covers test organization, assertions, mocking, and coverage.From its SKILL.md
npx -y skills add AtulPurohit/Antigravity-Awesome-Skills --skill unit-test-writerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.9 KB, 775 tokens by cl100k_base, as published. Nobody here has run it
Unit Test Writer
Purpose
Write unit tests that catch bugs early, document intended behavior, and give confidence to refactor.
Test Philosophy
- Test behavior, not implementation
- Each test should be: Fast, Independent, Repeatable, Self-validating
- Test the public interface, not internals
- One concept per test
Test Examples
JavaScript/TypeScript with Jest
describe('UserService', () => {
let service: UserService;
let mockRepo: jest.Mocked<UserRepository>;
let mockEmail: jest.Mocked<EmailService>;
beforeEach(() => {
mockRepo = {
findByEmail: jest.fn(),
create: jest.fn(),
} as any;
mockEmail = { sendWelcome: jest.fn() } as any;
service = new UserService(mockRepo, mockEmail);
});
describe('register', () => {
it('creates a user with hashed password', async () => {
mockRepo.findByEmail.mockResolvedValue(null);
mockRepo.create.mockResolvedValue({ id: '1', email: '[email protected]' });
await service.register({ email: '[email protected]', password: 'Secret123!' });
expect(mockRepo.create).toHaveBeenCalledWith(
expect.objectContaining({
email: '[email protected]',
password: expect.not.stringContaining('Secret123!'), // Password hashed
})
);
});
it('sends welcome email after registration', async () => {
mockRepo.findByEmail.mockResolvedValue(null);
mockRepo.create.mockResolvedValue({ id: '1', email: '[email protected]' });
await service.register({ email: '[email protected]', password: 'Secret123!' });
expect(mockEmail.sendWelcome).toHaveBeenCalledWith('[email protected]');
});
it('throws ConflictError if email already exists', async () => {
mockRepo.findByEmail.mockResolvedValue({ id: '1', email: '[email protected]' });
await expect(
service.register({ email: '[email protected]', password: 'Secret123!' })
).rejects.toThrow(ConflictError);
expect(mockRepo.create).not.toHaveBeenCalled();
});
});
});
Python with pytest
import pytest
from unittest.mock import Mock, patch
@pytest.fixture
def user_service():
mock_repo = Mock()
mock_email = Mock()
return UserService(mock_repo, mock_email), mock_repo, mock_email
class TestUserService:
def test_register_creates_user(self, user_service):
service, mock_repo, _ = user_service
mock_repo.find_by_email.return_value = None
mock_repo.create.return_value = User(id="1", email="[email protected]")
service.register(email="[email protected]", password="Secret123!")
mock_repo.create.assert_called_once()
created_user = mock_repo.create.call_args[0][0]
assert created_user.password != "Secret123!" # Hashed
def test_register_raises_if_email_taken(self, user_service):
service, mock_repo, _ = user_service
mock_repo.find_by_email.return_value = User(id="1", email="[email protected]")
with pytest.raises(ConflictError):
service.register(email="[email protected]", password="Secret123!")
Test Organization
tests/
├── unit/
│ ├── services/
│ ├── models/
│ └── utils/
├── integration/
│ └── api/
└── e2e/
Outputs
- Test suite for specified modules
- Test helpers and factories
- Mock configuration
- Coverage configuration
- CI integration for test runs
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.