如何使用 Test::Unit 跳过某些测试 [英] How to skip certain tests with Test::Unit

查看:41
本文介绍了如何使用 Test::Unit 跳过某些测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个项目中,我需要与多个后端系统协作.其中一些在文档中有些缺乏,部分原因是我有一些测试代码与一些测试服务器交互,只是为了看到一切都按预期工作.但是,访问这些服务器的速度非常慢,因此我不想每次运行测试套件时都运行这些测试.

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.

我的问题是如何处理您想跳过某些测试的情况.目前,我使用环境变量BACKEND_TEST"和条件语句,该语句检查是否为我想跳过的每个测试设置了该变量.但有时我想跳过测试文件中的所有测试,而不必在每个测试的开头添加额外的行.

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.

必须与测试服务器交互的测试并不多,因为我在其他情况下使用 flexmock.然而,你不能嘲笑自己远离现实.

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.

从这个问题的标题可以看出,我正在使用 Test::Unit.此外,如果有任何区别,则该项目是一个 Rails 项目.

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 2.x 的新特性 表明 test-unit 2.x(gem 版本,而不是 ruby​​ 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.

这篇关于如何使用 Test::Unit 跳过某些测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆