如何为单元测试创建虚拟数据? [英] how to create dummy data for unit test?
问题描述
我需要在测试环境中插入虚拟数据,以便我可以对其执行单元测试,但是我不知道如何在BootStrap上声明它(仅用于测试,不适用于所有环境)
你能帮助我吗?提前感谢您
如上所述,您可以使用测试夹具。您也可以将代码放入引导程序中一>。如果你使用的是junit 4,你可以使用@BeforeClass。另外,还有一些可能值得关注的 build-test-data插件。 / p>
如果您确实是指单元测试(与集成测试相对),请查看 grails testing插件(这些运行速度很快)。
I need to insert dummy data on test environtment so that I can run unit test on it but I don't know how to declare it on BootStrap (just for testing, not for all environtment)
can you help me ? thank you in advance
as noted, you can use the test fixture. you can also put code in bootstrap. if you are using junit 4, you might be able to use @BeforeClass. also, there is the build-test-data plugin that may be of interest.
if you really mean unit test (as opposed to integration test), take a look at the grails testing plugin (these run fast).
这篇关于如何为单元测试创建虚拟数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!