简体   繁体   English

运行所有 Python bdd 行为和单元测试

[英]Run all Python bdd Behave and unittest

I have a python application with a number of unit tests which I implemented using unittest library.我有一个 python 应用程序,其中包含我使用 unittest 库实现的许多单元测试。

There are also a number of bdd tests which I implemented using Behave package.还有一些我使用 Behave package 实现的 bdd 测试。

Is there a way to run all of the unit tests along with the bdd tests from one python file and fail as soon as any of the tests fail?有没有办法从一个 python 文件中运行所有单元测试以及 bdd 测试,并在任何测试失败时立即失败?

I'm not sure how you invoke the unit tests, but you could add a behave feature file that would implement steps to run the unit tests.我不确定您如何调用单元测试,但您可以添加一个行为特征文件,该文件将实现运行单元测试的步骤。 This could just be a another feature within the behave framework, eg, "all unit tests pass" and you could have a scenario like:这可能只是行为框架中的另一个功能,例如,“所有单元测试都通过”,您可能会有这样的场景:

Scenario: All unit tests pass
Given the application is ready to test
When I run the unit tests
Then all unit tests have passed

And your unit tests will be executed as part of the behave invocation.您的单元测试将作为行为调用的一部分执行。

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

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