Share data between TestNG tests without static fields
QuizMediumJava only
One test creates an order. A later test in the same <test> block needs the order id. Which TestNG feature passes the id without a static field?
- Add an
ITestContextparameter; callsetAttribute("orderId", id)in one test andgetAttribute("orderId")in the other @Parameters("orderId")System.setPropertyin one test, read it in the other- It is impossible in TestNG
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.