擅长:python、mysql、java
<p>在我看来,您并不是真正的单元测试。函数和单元测试中的结构完全相同。因此,如果您的代码更改,测试也必须更改。我认为测试“=”操作符不值得你花时间。你知道吗</p>
<p>我可能错了,但我认为你应该有一个函数,获取doc1和doc2并返回一个响应。然后对特定输入值的返回值进行单元测试。像这样:</p>
<pre><code>result = foo(doc1,doc2)
self.assert_equal(result.message, "Bad request, empty body.")
result = foo(doc3,doc4)
self.assert_equal(result.message, "OK.")
</code></pre>
<p>一般来说,让你的代码“单元可测试”会更好。你知道吗</p>