From the knowledge I have acquired while doing automation with other tools, I want to ask about specifics of doing that in Selenium (with Java). Questions:
I remember watching a video on Junit where all the assert methods are wrapped up in a try block and an additional library is imported to make sure that a test fails, if an assert fails. How common is that approach?
Contrary to above, some say that you should never put assert methods in a try block. If you do that, running a java file will pass, even if an assert fails. Is doing this way also common?
If you have many tests to run, is it common to sort returns of assert methods in an excel file and later run only those tests, where asserts return false?
If you do continuous integration, it is important, from the way I understand, for a run to fail, if an assert method returns false. Otherwise, unfixed bugs will be deployed into production. Am I right and if so, how do you assure that that happens?
-
@NarendraC Hello. You suggested edits to this question and I accepted it, but it has not been answered yet. Could you please try to answer. ThanksRichardson– Richardson2016年08月16日 16:27:23 +00:00Commented Aug 16, 2016 at 16:27
1 Answer 1
Best of my knowledge, sharing answers hope it will help
Answer 1:
- Yes. Assert failure should fail test case too. I'm keeping same practice and even many documents pointing towards this practice.
- I will suggest we should avoid repetitive use of same Assertion
Answer 2:
- No, I have different opinion. We should use assertion
- Assertion -> If condition failed, program explicitly gets terminated. This is the power and if fails we can figure something is not working as expected
Answer 3:
- Its possible to re-run only those tests which get failed using TextNG
- Check this
Answer 4:
- Continuous Integration, used to execute our tests continuously
- "run to fail" is it really? I think we execute test to confirm that it gets pass means everything is working fine & as expected
- As mentioned above, Assert has power to restrict and terminate execution if condition fails
- Due to this we always ensure that unfixed bugs must not be deployed into production [Automation is not a replacement to manual testing for deployment of application]
Explore related questions
See similar questions with these tags.