TestPrune.Falco
When you change a route handler, only re-run the integration tests that hit that route.
This is an extension for TestPrune
that connects Falco URL routes to integration tests. If you change the
handler for /api/users/{id}, it finds the tests that make requests to
that URL and runs just those.
Installation
|
How to use it
1. Store your route mappings during indexing
Tell TestPrune which source files handle which URLs:
db.RebuildRouteHandlers [
{ UrlPattern = "/api/users/{id}"
HttpMethod = "GET"
HandlerSourceFile = "src/Web/Handlers/Users.fs" }
{ UrlPattern = "/api/users/{id}"
HttpMethod = "PUT"
HandlerSourceFile = "src/Web/Handlers/Users.fs" }
]
2. Create the extension and query affected tests
let extension =
FalcoRouteExtension(
integrationTestProject = "MyApp.IntegrationTests",
integrationTestDir = "tests/MyApp.IntegrationTests"
)
let affected =
(extension :> ITestPruneExtension)
.FindAffectedTests db changedFiles repoRoot
// -> [{ TestProject = "MyApp.IntegrationTests"; TestClass = "UsersTests" }]
How it works
- Checks if any changed file is a known handler (from the route table)
- Looks up which URL patterns that handler serves
-
Scans your integration test
.fsfiles for those URLs (/api/users/{id}matches/api/users/123in your test code) - Returns the test classes from files that reference affected routes
Documentation
val extension: obj
val affected: obj
TestPrune