I use try catch block for test cases. I catch exception and retry for at most 3 times. But when the test case pass with retry, the status of the test case is still failed. I think this is not reasonable.
Or is there a way to force the test case status to passed?
2 Likes
Once I use the try catch statement and catch the exception, even if I handle it properly, the test case is ma
Once I use the try catch statement and catch the exception, even if I handle it properly, the test case is regarded as failed.
Can you post me your script and also its execution logs?
Vinh Nguyen said:
Can you post me your script and also its execution logs?
@“Vinh Nguyen”
My test code is:
WebUI.openBrowser('')
try { WebUI.click(findTestObject('Page_Google/input_lsb'))} catch (Exception e) { e.printStackTrace()}
WebUI.navigateToUrl('https://www.google.com')
WebUI.setText(findTestObject('Page_Google/input_q'), 'katalon')
WebUI.click(findTestObject('Page_Google/input_lsb'))
WebUI.closeBrowser()
When I run the test case, it is marked as passed.
But when I run it in a test suite, it is marked as failed. As the picture shows.
Snip20180119_135.png
Vinh Nguyen said:
Can you post me your script and also its execution logs?
@“Vinh Nguyen”
Another problem I find is: if I run the following test case in a test suite, no html report is generated.
In the test case, I force the first try to fail, and it will pass for the second try. Then no test report is generated for every time I run it in a test suite.
for (it in 1…3) {
try {
WebUI.openBrowser('')
'Force fail for the first time'
if(it < 2) WebUI.click(findTestObject('Page\_Google/input\_lsb'))
WebUI.navigateToUrl('https://www.google.com')
WebUI.setText(findTestObject('Page\_Google/input\_q'), 'katalon')
WebUI.click(findTestObject('Page\_Google/input\_lsb'))
WebUI.closeBrowser()
break
} catch (Exception e) {
if(it >= 3) {
throw e
}
}
}
Snip20180119_137.png
Hi Andy Zhang
Please provide me your project also so that I can try executing from here
Vinh Nguyen said:
Hi Andy Zhang
Please provide me your project also so that I can try executing from here
@“Vinh Nguyen”
I have created a project on Github. GitHub - zyong812/katalon_demo
You can clone and run the test suites. The problems I mentioned will reappear
Hi Andy,
I’ve tried both of your Test Suites within that project and don’t observe your problems:
1. no_html_report:
HTML report is generated correctly after I execute this Test Suite.
2. try_catch_failed_status:
Log Viewer and Test Suite’s report have the same test case’s status.
So can you double check again on your side?
Screen Shot 2018-01-22 at 10.26.52.png
Screen Shot 2018-01-22 at 10.29.28.png
@“Vinh Nguyen” Thank you.
But I replay the problem again. So strange!
I have attached my report here katalon_demo/Reports at master · zyong812/katalon_demo · GitHub.
Which version of Katalon do you use?
1. no html report
2. failed status
Snip20180122_2.png
Snip20180122_3.png
Hi Andy,
I’m using 5.2 version which is downloaded from our website. I will try again to see if I can observe your issues.
Regards
I am also having the try\catch issue. Any updates on this?
I’ve created a minimal reproduction of the bug that can be used by the Katalon team to hopefully diagnose and fix the issue as it’s affecting our test runs too. Clone this repository and then run the batch file. Check the reports directory for the project and see whether all five expected JUnit reports were generated or not. If not, clear the reports directory and run it again. The bug typically manifests within 3-5 runs of the batch file:
Some of the error messages I’ve spotted in the test runner’s standard error stream are:
System is unable to generate report. Reason: For input string: ".2200118E4.2200118E4"
System is unable to generate report. Reason: For input string: ".2200118E4."
System is unable to generate report. Reason: For input string: "E1.37E1"
System is unable to generate report. Reason: For input string: "E1"
System is unable to generate report. Reason: multiple points
@Andy Davies said:
I’ve created a minimal reproduction of the bug that can be used by the Katalon team to hopefully diagnose and fix the issue as it’s affecting our test runs too. Clone this repository and then run the batch file. Check the reports directory for the project and see whether all five expected JUnit reports were generated or not. If not, clear the reports directory and run it again. The bug typically manifests within 3-5 runs of the batch file:
GitHub - BluewireTechnologies/katalon-missing-reports-bug-reproduction
Some of the error messages I’ve spotted in the test runner’s standard error stream are:
System is unable to generate report. Reason: For input string: ".2200118E4.2200118E4"
System is unable to generate report. Reason: For input string: ".2200118E4."
System is unable to generate report. Reason: For input string: "E1.37E1"
System is unable to generate report. Reason: For input string: "E1"
System is unable to generate report. Reason: multiple points
Thanks Andy. We will take a look at this and inform to you as soon as possible when we found the root cause.
@Vinh Nguyen Any updates about the fix?
@Vinh Nguyen
This issue might be connected to this one:
http://forum.katalon.com/discussion/comment/13608#Comment_13608
I was also using the try/catch block, and even though the test passes, Katalon Analytics shows it as failed if the “try” is unsuccessful.
I’ve got the same issue. I’ve hit an exception (which is expected) and I’ve caught it.
However the test is marked as failed/errored, but because I’ve caught that I want a pass.