在多线程中拆分 nunit 测试
我测试了一个商店网站。我对一名用户进行了测试。测试是连续的并且需要很长时间。问题在于,当针对同一用户的测试并行运行时,它们可能会相互干扰(例如,在一个测试中,该商品被添加到购物车,而在另一个测试中,该商品被删除)。我想添加第二个用户并并行运行测试。所以我需要以某种方式指定不同用户的测试在不同的线程中执行。 不幸的是,属性[Parallelizable]并没有提供这样的机会。是否有某种方法可以显式指定每个线程中应运行哪些测试?
I test a shop website. I have tests for one user. The tests are sequential and take a long time. The problem is that when tests for same user are run in parallel, they can interfere with each other (for example, in one test, the item was added to the cart, and in the other it was removed). I want to add a second user and run the tests in parallel. So I need to somehow specify that tests for different users are executed in different threads.
Unfortunately, the attribute [Parallelizable] does not provide such an opportunity. Is there some way to explicitly specify which tests should be run in each of the threads?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建用户提供者。
在该类中,您应该创建一个用户集合。
您需要两种方法:
1 - 从集合中获取和删除用户。
2 - 返回用户到集合
所有方法都应该用
lock
包装。返工测试方法,例如:
Create UserProvider.
In that class, you should create a collection with users.
And you need two methods:
1 - get and delete the user from the collection.
2 - back user to collection
All methods should be wrapped with
lock
.Rework test methods like: