- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的应用程序编写测试用例,我的大部分 Controller 都包含 CRUD 的通用代码,因此我编写了通用宏并在我的 Controller 中使用它。所有 Controller 的测试用例都将自动编写。但是我对如何使这个通用代码可重写感到困惑,以便我可以随时重写。
defmodule Qserv.ControllerTest do
defmacro __using__(_options) do
quote location: :keep do
use Qserv.Web.ConnCase, async: true
# this kernel will give me access to current `@model` and `@controller`
use Qserv.KernelTest
describe "#{@controller}.create/2" do
test "All required fields set `required` in model should generate errors that these fields are missing -> One, two, All"
test "Only required fields should create record and match the object"
end
# defoverridable index: 2, I want to override above `describe` completely or/and the included test cases
end
end
end
任何帮助/想法如何实现这一目标?
最佳答案
我通常不喜欢“让我们稍后再做一些事情来撤消它”。它通常会迫使开发人员在他们的头脑中保留一个堆栈,以了解以后如何添加和删除内容。
特别是在这种情况下,您要耦合测试名称。想象一下,有人决定将“一、二、全部”中的“二”变成大写。现在所有 future 的覆盖都将不适用,您将有重复的测试。
明确选择所需内容的更好解决方案。例如,您可以定义在必要时使用的更小的宏:
describe_create!
describe_update!
...
describe_delete!
也许您可以使用 describe_restful!
来调用所有这些。这里的教训是在其上构建小的构建 block ,而不是稍后尝试分解的大块。
PS:请使用比我使用的 describe_x
更好的名称。 :)
关于testing - exunit 测试用例的可覆盖宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48759626/
我最近购买了《C 编程语言》并尝试了 Ex 1-8这是代码 #include #include #include /* * */ int main() { int nl,nt,nb;
早上好!我有一个变量“var”,可能为 0。我检查该变量是否为空,如果不是,我将该变量保存在 php session 中,然后调用另一个页面。在这个新页面中,我检查我创建的 session 是否为空,
我正在努力完成 Learn Python the Hard Way ex.25,但我无法理解某些事情。这是脚本: def break_words(stuff): """this functio
我是一名优秀的程序员,十分优秀!