简体   繁体   English

相关测试

[英]Dependent Tests

Alright, so I'm using the Microsoft Test Framework for testing and I need to somehow build dependent tests. 好吧,所以我正在使用Microsoft测试框架进行测试,我需要以某种方式构建依赖测试。 Why you might say? 你为什么要说? Because one of the tests ensures that I can load data from the database and the others need to operate against that set -- making the round trips is something we don't want to do to keep the automated nature of the tests efficient. 因为其中一项测试可确保我可以从数据库中加载数据,而其他一些测试则需要针对该集合进行操作-进行往返旅行是我们不希望做的,以保持测试的自动化性质高效。

I have been searching and just can't seem to find a way to do a couple of things: 我一直在搜索,但似乎无法找到一种方法来做几件事:

  1. Decorate the test methods so that they are seen as dependent. 装饰测试方法,使它们被视为依赖。
  2. Persist the set between tests. 在测试之间坚持设置。

What have I tried? 我尝试了什么?

Well, regarding the decoration for dependent tests, not much because I can't seem to find an attribute that's built for that. 好吧,关于依赖测试的修饰,并不是很多,因为我似乎找不到为此而建立的属性。

Regarding the persistence of the set, I've tried a private class variable and adding to the Properties of the test context. 关于集合的持久性,我尝试了一个私有类变量并将其添加到测试上下文的Properties中。 Both of those have resulted in the loss of the set between tests. 两者都导致测试之间的集合丢失。

I hope that you can help me out here! 希望您能在这里帮助我!

Create your test separately and then use the Ordered Test to run them in the order you want. 分别创建测试,然后使用“ 有序测试”以所需顺序运行它们。

If any of the tests fails then the whole test is aborted and it considered failed: 如果任何测试失败,则整个测试将中止,并认为失败:

在此处输入图片说明

I think, what you need is an orderer test list . 我认为,您需要的是orderer test list You can create this in you test project under 'New Item...'. 您可以在测试项目的“新建项目...”下创建此项目。 The ordered test list is a list with tests in a specified order that are executed in the same context . 有序测试列表是具有在相同context中执行的指定顺序测试的列表。

By the way: Unit tests should test only the smallest unit in an application, not a huge set of operations. 顺便说一句:单元测试应该只测试应用程序中最小的单元,而不是大量的操作。 Because if one unit is not working correctly you can find easy wich one. 因为如果一台设备不能正常工作,则可以轻松找到一台。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM