首页/ AI 技能 / @skilllib/skill-2117939930272417813
Skill站外收录 @skilllib/skill-2117939930272417813

wheels-test-generator

自动生成符合 Wheels 框架规范的 TestBox BDD 测试代码,覆盖模型验证与关联、控制器动作与过滤器、以及端到端集成流程,内置标准 setup/teardown 逻辑和典型测试用例结构。

0.0 (0) 16 次安装 原作者 编程导航
收录于 2026-01-22
测试与安全 AI 技能

Skills.MD

# Wheels Test Generator ## When to Use This Skill Activate automatically when: - User requests to create tests/specs - User wants to test a model, controller, or workflow - User mentions: test, spec, TestBox, BDD, describe, it, expect - After generating models/controllers (proactive testing) ## Model Test Template ```cfm component extends="wheels.Test" { function setup() { // Runs before each test super.setup(); model = model("Post").new(); } function teardown() { // Runs after each test if (isObject(model) && model.isPersisted()) { model.delete(); } super.teardown(); } function testValidatesPresenceOfTitle() { model.title = ""; assert("!model.valid()"); assert("model.hasErrors('title')"); } function testHasManyComments() { model = model("Post").create(title="Test", content="Content"); comment = model("Comment").create(postId=model.id, content="Comment"); assert("model.comments().recordCount == 1"); model.delete(); // Cascade should delete comment assert("!isObject(model('Comment').findByKey(comment.id))"); } } ``` ## Controller Test Template ```cfm component extends="wheels.Test" { function setup() { super.setup(); params = {controller="posts", action="index"}; } function testIndexLoadsAllPosts() { controller = controller("Posts", params); controller.processAction("index"); assert("isQuery(controller.posts)"); } function testShowRequiresKey() { params.action = "show"; controller = controller("Posts", params); // Should redirect due to missing key } function testCreateWithValidData() { params.action = "create"; params.post = {title="Test", content="Content"}; controller = controller("Posts", params); controller.processAction("create"); assert("flashKeyExists('success')"); } } ``` ## Integration Test Template ```cfm component extends="wheels.Test" { function testCompletePostLifecycle() { // Create post = model("Post").create(title="Test", content="Content"); assert("isObject(post) && post.isPersisted()"); // Update post.update(title="Updated"); assert("post.title == 'Updated'"); // Add comment comment = model("Comment").create(postId=post.id, content="Comment"); assert("post.comments().recordCount == 1"); // Delete (cascade) post.delete(); assert("!isObject(model('Comment').findByKey(comment.id))"); } } ``` ## Related Skills - **wheels-model-generator**: Creates models to test - **wheels-controller-generator**: Creates controllers to test --- **Generated by:** Wheels Test Generator Skill v1.0

评论 0

还没有评论,来抢沙发。