如何在Fitnesse中测试近似值 [英] How to test approximate values in Fitnesse

查看:98
本文介绍了如何在Fitnesse中测试近似值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Fitnesse与FitSharp结合使用来运行集成测试.我正在使用RowFixture测试数字结果表,并且需要能够测试大约3个小数位的近似值.我怎样才能做到这一点?我读过有关使用〜=的内容,但这似乎不适用于表

I'm using Fitnesse with FitSharp to run integration tests. I'm using the RowFixture to test a table of numerical results and need to be able to test an approximate value to about 3 decimal places. How can I achieve this? I read somewhere about using ~= but this does not appear to work on tables

推荐答案

是的,FitNesse中的Slim测试系统提供了大约等于运算符(~=),但我同意fitSharp中 not 不可用.需要考虑的两种可能性:

Yes, the Slim Test System in FitNesse offers an approximately equals operator (~=) as you point out but I agree that it is not available in fitSharp. Two possibilities to consider:

首先(尽管我没有机会使用它们)fitSharp提供了多种单元格运算符-特别是该列表上的比较发泡点.

First (though I have not had occasion to use them) fitSharp offers a variety of cell operators--see, in particular, Compare Foating Point on that list.

第二,我使用的一种技术是:

Second, one technique I have used is this:

也就是说,我的Math夹具允许您指定精度(如果未指定,则默认为两个位置).后面的代码非常简单:

That is, my Math fixture lets you specify a precision (defaulting to two places if unspecified). The code-behind for that is quite simple:

    private double DoCalculation()
    {
        . . .
        return Math.Round(_result, Precision);
    }

这篇关于如何在Fitnesse中测试近似值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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