(一些)测试在通过纽曼运行Postman收集时失败,但在Postman中运行时通过

xwbd5t1u  于 2022-11-07  发布在  Postman
关注(0)|答案(1)|浏览(284)

当运行我的Postman集合时,我在整个套件中收到0个错误,但在纽曼中,两个请求中的测试失败。
这些是我的PM测试+相关机构:

testsuite = "T5 - FeederConfigurator - Unit - Calculate - "

var jsonData = JSON.parse(responseBody);

pm.test(testsuite + "Status code is 200", function () {pm.response.to.have.status(200);});
pm.test(testsuite + "Succes (true)", function() {pm.expect(jsonData.success).to.eql(true); });
pm.test(testsuite + "No Errors", function() {pm.expect(jsonData.error).to.eql(null); });
pm.test(testsuite + "FishPerHa", function() {pm.expect(jsonData.result.ufsrFishPerHa).to.eql(0)});
pm.test(testsuite + "FeederCountRecommended", function() {pm.expect(jsonData.result.ufsrFeederCountRecommended).to.eql(1)});
pm.test(testsuite + "TimeRangeStart_1", function() {pm.expect(jsonData.result.ufsrTimeRangeResults[0].utrStartTime).to.eql('00:00')});

相关机构{“结果”:{“用户鱼总数”:25000,“用户存活百分比”:100.0,“每公顷捕鱼量”:0,“超生物量”:1.25659535973556,“饲料生物量百分比”:0.0045201895240963965,“进给量”:5.68004918110482,“用户送纸器计数”:11,“推荐的送纸机计数”:1、“ufsrFeederTimeGap”:11、“ufsrTimeRange结果”:[ {“utrTime范围编号”:1、“utrStartTime”:“00:00”、“utrStopTime”:“00:00”,

testsuite = "T5 - FeederConfigurator - Unit - Calculate by Id - "

var jsonData = JSON.parse(responseBody);

pm.test(testsuite + "Status code is 200", function () {pm.response.to.have.status(200);});
pm.test(testsuite + "Succes (true)", function() {pm.expect(jsonData.success).to.eql(true); });
pm.test(testsuite + "No Errors", function() {pm.expect(jsonData.error).to.eql(null); });
pm.test(testsuite + "FishPerHa", function() {pm.expect(jsonData.result.ufsrFishPerHa).to.eql(0)});
pm.test(testsuite + "FeederCountRecommended", function() {pm.expect(jsonData.result.ufsrFeederCountRecommended).to.eql(1)});
pm.test(testsuite + "TimeRangeStart_1", function() {pm.expect(jsonData.result.ufsrTimeRangeResults[0].utrStartTime).to.eql('00:00')});

相关机构{“结果”:{“用户鱼总数”:25000,“用户存活百分比”:100.0,“每公顷捕鱼量”:0,“超生物量”:1.25659535973556,“饲料生物量百分比”:0.0045201895240963965,“进给量”:5.68004918110482,“用户送纸器计数”:11,“推荐的送纸机计数”:1、“ufsrFeederTimeGap”:11、“ufsrTimeRange结果”:[ {“utrTime范围编号”:1、“utrStartTime”:“00:00”、“utrStopTime”:“00:00”,

当通过纽曼运行它时,我得到以下错误:

01.  AssertionError  T5 - FeederConfigurator - Unit - Calculate - Succes (true)                
                      expected false to deeply equal true                                       
                      at assertion:1 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Calculate"                  

 02.  AssertionError  T5 - FeederConfigurator - Unit - Calculate - No Errors                    
                      expected { Object (code, message, ...) } to deeply equal null             
                      at assertion:2 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Calculate"                  

 03.  TypeError       T5 - FeederConfigurator - Unit - Calculate - FishPerHa                    
                      Cannot read properties of null (reading 'ufsrFishPerHa')                  
                      at assertion:3 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Calculate"                  

 04.  TypeError       T5 - FeederConfigurator - Unit - Calculate - FeederCountRecommended       
                      Cannot read properties of null (reading 'ufsrFeederCountRecommended')     
                      at assertion:4 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Calculate"                  

 05.  TypeError       T5 - FeederConfigurator - Unit - Calculate - TimeRangeStart_1             
                      Cannot read properties of null (reading 'ufsrTimeRangeResults')           
                      at assertion:5 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Calculate"

 06.  AssertionError  T5 - FeederConfigurator - Unit - Calculate by Id - Succes (true)          
                      expected false to deeply equal true                                       
                      at assertion:1 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Id/Calculate"               

 07.  AssertionError  T5 - FeederConfigurator - Unit - Calculate by Id - No Errors              
                      expected { Object (code, message, ...) } to deeply equal null             
                      at assertion:2 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Id/Calculate"               

 08.  TypeError       T5 - FeederConfigurator - Unit - Calculate by Id - FishPerHa              
                      Cannot read properties of null (reading 'ufsrFishPerHa')                  
                      at assertion:3 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Id/Calculate"               

 09.  TypeError       T5 - FeederConfigurator - Unit - Calculate by Id - FeederCountRecommended 
                      Cannot read properties of null (reading 'ufsrFeederCountRecommended')     
                      at assertion:4 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Id/Calculate"               

 10.  TypeError       T5 - FeederConfigurator - Unit - Calculate by Id - TimeRangeStart_1       
                      Cannot read properties of null (reading 'ufsrTimeRangeResults')           
                      at assertion:5 in test-script                                             
                      inside "T5 - FeederConfigurator / Unit / Unit/Id/Calculate"
o8x7eapl

o8x7eapl1#

我找到了解决方案,我的初始值和当前值在环境变量中是不一样的。PM使用当前值,而纽曼使用初始值。

相关问题