원클릭으로
write-tests
Create unit tests for API controllers (MSTest) or Angular components (Jasmine). Follows project testing patterns and conventions.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Create unit tests for API controllers (MSTest) or Angular components (Jasmine). Follows project testing patterns and conventions.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | write-tests |
| description | Create unit tests for API controllers (MSTest) or Angular components (Jasmine). Follows project testing patterns and conventions. |
| allowed-tools | ["Read","Glob","Grep","Edit","Write","Bash(dotnet test:*)","Bash(npm test:*)"] |
Load this skill when creating unit tests for API controllers or Angular components.
| Testing... | Also load |
|---|---|
| API controllers | api-patterns.md (for controller conventions) |
| Angular components | angular-patterns.md (for component conventions) |
Create tests in Neptune.Tests project.
[TestClass]
public class EntityControllerTests
{
private NeptuneDbContext _dbContext;
private EntityController _controller;
[TestInitialize]
public void Setup()
{
var options = new DbContextOptionsBuilder<NeptuneDbContext>()
.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
.Options;
_dbContext = new NeptuneDbContext(options);
var neptuneConfiguration = Options.Create(new NeptuneConfiguration());
_controller = new EntityController(
_dbContext,
Mock.Of<ILogger<EntityController>>(),
neptuneConfiguration
);
}
[TestMethod]
public async Task List_ReturnsAllEntities()
{
// Arrange
_dbContext.Entities.Add(new Entity { Name = "Test" });
await _dbContext.SaveChangesAsync();
// Act
var result = await _controller.List();
// Assert
Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult));
var okResult = (OkObjectResult)result.Result;
var entities = (List<EntityGridDto>)okResult.Value;
Assert.AreEqual(1, entities.Count);
}
[TestMethod]
public async Task GetByID_ReturnsEntity_WhenExists()
{
// Arrange
var entity = new Entity { EntityID = 1, Name = "Test" };
_dbContext.Entities.Add(entity);
await _dbContext.SaveChangesAsync();
// Act
var result = await _controller.GetByID(1);
// Assert
Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult));
}
[TestMethod]
public async Task GetByID_ReturnsNotFound_WhenNotExists()
{
// Act
var result = await _controller.GetByID(999);
// Assert
Assert.IsInstanceOfType(result.Result, typeof(NotFoundResult));
}
}
{MethodName}_{ExpectedBehavior}_{Condition}
Examples:
List_ReturnsAllEntitiesGetByID_ReturnsEntity_WhenExistsGetByID_ReturnsNotFound_WhenNotExistsCreate_ReturnsCreatedEntity_WhenValidUpdate_ReturnsNoContent_WhenSuccessfulNeptune uses ApprovalTests for snapshot-based testing. Approved output files use .approved.txt extension:
[TestMethod]
public void SomeOutput_MatchesApproved()
{
var result = SomeMethodThatProducesOutput();
Approvals.Verify(result);
}
When test output changes, update the .approved.txt file to match.
Neptune controllers take 3 parameters — NeptuneDbContext, ILogger<T>, and IOptions<NeptuneConfiguration>. Make sure your test setup mocks all three:
var neptuneConfiguration = Options.Create(new NeptuneConfiguration());
var controller = new EntityController(
dbContext,
Mock.Of<ILogger<EntityController>>(),
neptuneConfiguration
);
Component tests in *.spec.ts files alongside components.
describe('EntityDetailComponent', () => {
let component: EntityDetailComponent;
let fixture: ComponentFixture<EntityDetailComponent>;
let entityServiceSpy: jasmine.SpyObj<EntityService>;
beforeEach(async () => {
entityServiceSpy = jasmine.createSpyObj('EntityService', ['getByID']);
await TestBed.configureTestingModule({
imports: [EntityDetailComponent],
providers: [
{ provide: EntityService, useValue: entityServiceSpy }
]
}).compileComponents();
fixture = TestBed.createComponent(EntityDetailComponent);
component = fixture.componentInstance;
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should load entity when entityID is set', fakeAsync(() => {
const mockEntity = { entityID: 1, name: 'Test Entity' };
entityServiceSpy.getByID.and.returnValue(of(mockEntity));
component.entityID = '1';
tick();
component.entity$.subscribe(entity => {
expect(entity).toEqual(mockEntity);
});
expect(entityServiceSpy.getByID).toHaveBeenCalledWith(1);
}));
it('should display entity name in template', fakeAsync(() => {
const mockEntity = { entityID: 1, name: 'Test Entity' };
entityServiceSpy.getByID.and.returnValue(of(mockEntity));
component.entityID = '1';
fixture.detectChanges();
tick();
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.card-title').textContent).toContain('Test Entity');
}));
});
// Create spy with methods
const serviceSpy = jasmine.createSpyObj('ServiceName', ['method1', 'method2']);
// Configure return values
serviceSpy.method1.and.returnValue(of(mockData));
serviceSpy.method2.and.returnValue(throwError(() => new Error('Test error')));
// Provide in TestBed
providers: [{ provide: ServiceName, useValue: serviceSpy }]
# Run all tests
dotnet test Neptune.Tests/Neptune.Tests.csproj
# Run specific test by name
dotnet test Neptune.Tests/Neptune.Tests.csproj --filter "FullyQualifiedName~SomeTestName"
# Run tests with coverage
dotnet test Neptune.Tests/Neptune.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
cd Neptune.Web
npm test # Run tests once
Create or flesh out a Jira story with structured sections for POs, Devs, and Claude. Accepts an optional Jira key to update an existing card.
Export Water Quality Management Plans for one jurisdiction from the local Neptune database to an Esri File Geodatabase in native projection. Use when a client requests WQMP spatial data for a specific city/jurisdiction.
Extract rework items from a Jira card's Acceptance Criteria and produce a fix plan. Auto-detects issue key from branch or accepts one as argument.
Fetch a Jira card by key (e.g. NPT-100) and produce a detailed implementation plan. Use this when starting work on a new story.
Build the SQL Server DACPAC and scaffold EF Core entities. Run this after finishing all SQL schema edits in Neptune.Database/.
Add a scrollspy Table of Contents sidebar to a page component with signal-based scroll tracking.