即使期望表和实际表具有相同的值,TSQLT测试也会失败

nx7onnlm  于 2022-10-03  发布在  其他
关注(0)|答案(1)|浏览(96)

我收到错误失败:(失败)意外/缺少结果集行!对于tsqlt测试,即使预期的表和实际表具有相同的结果
Volume|90Day Volume|Relative90Dvol.
-|-|
4493|16413368.1429|95.119153740058

在上面的例子中,“Relative90Dval”是用in存储过程计算的。如果Relative90Dvol值是一个整数值,比如95,则测试通过,但如果该值是小数精度的浮点型,如95.119153740058,则测试失败。如何通过tsqlt测试处理这样的小数精确值。

failed: (Failure) Unexpected/missing resultset rows!
|_m_|symbol |exchange|session|Time                |Open   | Volume             |Volume.90D          |Relative90D.Pct             |insert_Date         |
+---+-------+--------+-------+--------------------+-------------------+------------------------+------+--------------------+--------------------+-------------------+------------+-----------------+-----------------------+----------------------+---------+----------------------------+--------------------+
|<  |TEST1.O|NSQ     |0      |4.479070000000000E+4|!NULL! |1.292000000000000E+3|6.923157219780000E+6|8.635296985604490E+1        |4.479070000000000E+4|
|<  |TEST2.O|NSQ     |0      |4.479070000000000E+4|!NULL! |2.229000000000000E+3|9.369240538460000E+6|1.100841107726760E+2        |4.479070000000000E+4|
|>  |TEST2.O|NSQ     |0      |4.479070000000000E+4|!NULL! |2.229000000000000E+3|9.369240538460000E+6|1.100841107726760E+2        |4.479070000000000E+4|
|>  |TEST1.O|NSQ     |0      |4.479070000000000E+4|!NULL! |1.292000000000000E+3|6.923157219780000E+6|8.635296985604490E+1        |4.479070000000000E+4|
rks48beu

rks48beu1#

我通常最终会采取一些“宽容”的态度。您可以通过以下方式轻松做到这一点:

declare @actual decimal(30,2);
declare @expected decimal(30,2) = 789.5;
declare @tolerance decimal(18,2) = 0.1;

IF @actual between @expected - @tolerance and @expected + @tolerance 
    set @actual = @expected;

EXEC tsqlt.AssertEquals @expected, @actual, @Message = '...';

相关问题