Skip to content
CodeKruPro

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 ITestContext parameter; call setAttribute("orderId", id) in one test and getAttribute("orderId") in the other
  • @Parameters("orderId")
  • System.setProperty in 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.

See Pro+

Already have Pro+? Sign in