2017-05-04 66 views
1

当我使用mocha/jasmine这样的工具时,我可以创建一组测试,这些测试由上下文进行聚合。 (使用describe关键字)我如何使用pytest创建套件/聚合测试

在创建测试的集合/聚合后,我在运行结果中看到它,并且我只能运行一组测试。

我该如何用pytest实现这个功能?

回答

1

您可以用彩笔组测试,类似于标签(或者grep的茉莉)

import pytest 

@pytest.mark.webtest 
def test_send_http(): 
    pass # perform some webtest test for your app 
def test_something_quick(): 
    pass 
def test_another(): 
    pass 
class TestClass: 
    def test_method(self): 
     pass 

与运行pytest -v -m webtest

另一种选择是按类 - 一间套房,是一类并用pytest运行这个类

+0

什么是-v -m标志? –

+0

-v代表verbose,-m代表使用标记 –

相关问题