首页 \ 问答 \ 我是否必须在每个TestCase中创建我的测试数据库条目?(Do I have to create my test database entries in each TestCase?)

我是否必须在每个TestCase中创建我的测试数据库条目?(Do I have to create my test database entries in each TestCase?)

我有一个电子商务应用程序,我有子应用程序,如productordercheckout等。 在每个应用程序中,我都有一个tests.py文件,其中包含对该应用程序的隔离部分的测试。

许多不同的测试用例/子应用程序使用相同类型的数据。 例如,产品测试,订单测试和结账测试都需要包含产品,购物车,货币等的样本数据。

目前我正在每个TestCasesetUp函数中创建此测试数据。 但这意味着我一遍又一遍地创建相同的数据,这看起来非常愚蠢和不必要。

我有什么方法可以为我的测试数据库创建“全局”测试数据吗? 在运行任何TestCase之前,这将首先创建? 或者我已经做了“正确”的方式,即使它看起来很糟糕?

我正在使用Django,它正在使用unittest python模块。


I have a ecommerce application where I have sub-applications such as product, order, checkout and so on. In each application I have a tests.py file containing test for that isolated part of the app.

Many of the different testcases/sub-apps use the same kind of data. For example, both product-tests, order-tests and checkout-tests need to have sample data for products, carts, currencies and so on.

Currently I'm creating this test data in the setUp function of each TestCase. But this means that I'm creating the same data over and over again, which seem very stupid and unnecessary.

Is there some way for me to create "global" test data for my test-database? That will be created first, before any TestCase is run? Or am I already doing the "correct" way, even though it seems bad?

I'm using Django, which is using the unittest python module.


原文:https://stackoverflow.com/questions/32708510
更新时间:2022-03-03 22:03

最满意答案

Xavier Perseguers的本教程告诉您使用索引搜索索引页面和记录所需的一切。 它是为TYPO3的老版本制作的(正如你可以从屏幕截图中看到的那样),但它也适用于更新的版本。


This tutorial by Xavier Perseguers tells you everything you need to do to index pages and records with Indexed Search. It was made for an older version of TYPO3 (as you can see from the screenshots) but it should work for newer releases too.

相关问答

更多
  • 没有开箱即用的解决方案。 但您可以使用以下内容:或创建自己的扩展程序,您可以在其中收集页面的类别并在页面上呈现它们。 然后,您还可以创建一种类别菜单。 您可以使用类别集合: http : //docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Categories/Index.html cObject RECORDS还有一个类别属性,因此您也可以使用typoscript进行渲染。 There is no out-of-the box solution f ...
  • 最后我找到了解决方案。 我必须使用PHP的CGI版本(在这种情况下是7.0.20) Finally I found the solution. I have to use the CGI Version of PHP (In this case 7.0.20)
  • 这听起来不像TYPO3的问题,而不是CSS的问题。 如果HTML标记在浏览器中可用但不可见,则浏览器已决定不显示它。 这可能是CSS。 使用浏览器调试器(firebug,inspector,...)来确定哪些CSS隐藏了内容。 此外,Javascript可能会互动,因为它可能会改变页面提交后的可视性 (尝试使用停用的JavaScript加载页面) 最后,它可能是一个额外的或缺少的div标签或css类是负责任的,你可以配置TYPO3以改变HTML标记的方式,以便您的内容不被隐藏。 如果您有一台服务器的内容可见 ...
  • 这是因为至少有一个模板被呈现(或至少被解析),其中使用VHS ViewHelper的ResourcesViewHelper及其来自pre命名空间时代的旧类名。 扫描您的流体模板(最有可能的页面模板)为旧的VHS名称空间声明 {namespace v=Tx_Vhs_ViewHelpers} 并将其更改为 {namespace v=FluidTYPO3\Vhs\ViewHelpers} 您也可以切换到在HTML标记中声明命名空间,如下所示:
    这是sitecore中的一个错误! 据报道,但没有估计何时修复。 该错误发生在Sitecore.ContentSearch.SitecoreItemCrawler.IsAncestorOf方法中,它没有进行正确的检查。 这是我从sitecore支持获得的建议: 与此同时,我们建议您实施以下解决方法来解决此问题: 创建一个派生自Sitecore.ContentSearch.SitecoreItemCrawler类的类。 覆盖其IsAncestorOf方法。 新方法应如下所示: protected overr ...
  • 您可以 使用 Page- / User TSConfig 为每个表在TYPO3中配置此行为: TCEMAIN { table { tt_content { // remove suffix from copied record disablePrependAtCopy = 1 // optionally you can set copied record visible with disa ...
  • 你的用户设置中是否启用了rte(标签:编辑和高级功能)? do you have rte enabled in your user settings (tab: Edit & Advanced functions)?
  • 只需创建自定义扩展,它将返回页面上的API数据和/或提供服务的类型,您需要禁用所有标头并允许您的插件生成原始JSON Just create custom extension which will return API data, on page and/or type serving it you need to disable all headers and allow your plugin to generate raw JSON
  • Xavier Perseguers的本教程告诉您使用索引搜索索引页面和记录所需的一切。 它是为TYPO3的老版本制作的(正如你可以从屏幕截图中看到的那样),但它也适用于更新的版本。 This tutorial by Xavier Perseguers tells you everything you need to do to index pages and records with Indexed Search. It was made for an older version of TYPO3 (as ...
  • 您必须将TYPO3 6.2升级到typo3 7.6.x. 在TYPO3 7.6中,typo3 defult tables and tables fileds主要变化。 因此,如果您不遵循所有INSTALL TOOLS Upgrade Wizard steps and compare database specification 。 然后首先按照所有这些步骤。 You have to upgrade TYPO3 6.2 to typo3 7.6.x. In TYPO3 7.6 major changes in ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)