How to test approximate values in Fitnesse

二次信任 提交于 2019-12-11 04:48:59

问题


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


回答1:


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:

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:

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);
    }



回答2:


Does the ~= operator do what you need? It's pretty easy to add to fitSharp.



来源:https://stackoverflow.com/questions/18489771/how-to-test-approximate-values-in-fitnesse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!