In one of my projects I need to collaborate with several backend systems. Some of them somewhat lacks in documentation, and partly therefore I have some test code that interact with some test servers just to see everything works as expected. However, accessing these servers is quite slow, and therefore I do not want to run these tests every time I run my test suite.
在我的一个项目中,我需要与几个后端系统协作。其中一些有些缺乏文档,部分因此我有一些测试代码与一些测试服务器交互只是为了看到一切按预期工作。但是,访问这些服务器的速度非常慢,因此我不希望每次运行测试套件时都运行这些测试。
My question is how to deal with a situation where you want to skip certain tests. Currently I use an environment variable 'BACKEND_TEST' and a conditional statement which checks if the variable is set for each test I would like to skip. But sometimes I would like to skip all tests in a test file without having to add an extra row to the beginning of each test.
我的问题是如何处理你想跳过某些测试的情况。目前我使用环境变量'BACKEND_TEST'和条件语句来检查是否为我想跳过的每个测试设置了变量。但有时我想跳过测试文件中的所有测试,而不必在每个测试的开头添加额外的行。
The tests which have to interact with the test servers are not many, as I use flexmock in other situations. However, you can't mock yourself away from reality.
必须与测试服务器交互的测试并不多,因为我在其他情况下使用flexmock。但是,你不能嘲笑自己远离现实。
As you can see from this question's title, I'm using Test::Unit. Additionally, if it makes any difference, the project is a Rails project.
从这个问题的标题可以看出,我正在使用Test :: Unit。此外,如果它有任何区别,该项目是一个Rails项目。
2 个解决方案
#1
8
New Features Of Test Unit 2.x suggests that test-unit 2.x (the gem version, not the ruby 1.8 standard library) allows you to omit tests.
测试单元2.x的新功能表明测试单元2.x(gem版本,而不是ruby 1.8标准库)允许您省略测试。
#2
7
The features referred to in the previous answer include the omit()
method and omit_if()
上一个答案中提到的功能包括omit()方法和omit_if()
def test_omission
omit('Reason')
# Not reached here
end
And
和
def test_omission
omit_if("".empty?)
# Not reached here
end
来自:http://test-unit.rubyforge.org/test-unit/en/Test/Unit/TestCaseOmissionSupport.html#omit-instance_method
#1
8
New Features Of Test Unit 2.x suggests that test-unit 2.x (the gem version, not the ruby 1.8 standard library) allows you to omit tests.
测试单元2.x的新功能表明测试单元2.x(gem版本,而不是ruby 1.8标准库)允许您省略测试。
#2
7
The features referred to in the previous answer include the omit()
method and omit_if()
上一个答案中提到的功能包括omit()方法和omit_if()
def test_omission
omit('Reason')
# Not reached here
end
And
和
def test_omission
omit_if("".empty?)
# Not reached here
end
来自:http://test-unit.rubyforge.org/test-unit/en/Test/Unit/TestCaseOmissionSupport.html#omit-instance_method