Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用java自动化实时数据_Java_Junit_Automation_Testng - Fatal编程技术网

使用java自动化实时数据

使用java自动化实时数据,java,junit,automation,testng,Java,Junit,Automation,Testng,我是自动化和Java的新手。我正在处理一个问题,这需要我从数据库中读取读取的股票市场数据,并用UI上显示的值验证它是否相同。我可以在值中使用高达5%的近似值。要验证这些测试是否已通过,我必须在UI中使用值断言这些值 我有一个验证这些值的小逻辑,我想知道这是一种在java上编码的好方法,还是有更好的方法来实现这些结果 算法 我从db读取int/float值 计算步骤1中数值的5% 在UI中获取值,并断言其是否大于或等于步骤2中的值 如果我说assert.assertEquals(真,真),否则我的

我是自动化和Java的新手。我正在处理一个问题,这需要我从数据库中读取读取的股票市场数据,并用UI上显示的值验证它是否相同。我可以在值中使用高达5%的近似值。要验证这些测试是否已通过,我必须在UI中使用值断言这些值

我有一个验证这些值的小逻辑,我想知道这是一种在java上编码的好方法,还是有更好的方法来实现这些结果

算法

  • 我从db读取int/float值
  • 计算步骤1中数值的5%
  • 在UI中获取值,并断言其是否大于或等于步骤2中的值
  • 如果我说assert.assertEquals(真,真),否则我的断言失败

  • 如果有更好的方法来处理这些值,请请求一个更好的答案。

    更常见的做法是让您的断言代表测试的意义,而必须断言(true,true)并不能做到这一点。因此:

     3. Calculate the absoluete difference between the value obtained in step 1 and the UI value (when I say absolute value, you need to remember that the UI might be higher or lower than the db value, you need to make the difference to be always positive)
     4. Assert.assertThat( difference < theFivePercentValue)
    
    3。计算步骤1中获得的值与UI值之间的绝对差值(当我说绝对值时,您需要记住UI可能高于或低于db值,您需要使差值始终为正值)
    4.Assert.assertThat(差值<百分之五的值)
    

    也可以考虑使用HAMCSTREST扩展到JUnit,其中包含一个CouthTo()方法。

    H.DJNA。谢谢。我正在寻找一个带有TestNG的选项,因为这是一个断言。在附近找到工作