Saturday, June 28, 2025

automated testing – How you can entry dependencies from check class


TestNG permits you to specify dependencies both with −

a.Utilizing attribute dependsOnMethods in @Check annotations, OR.

b.Utilizing attribute dependsOnGroups in @Check annotations.

Instance Utilizing dependsOnMethods

  • Create a java class to be examined, say, MessageUtil.java

  • Create a java check class, say, DependencyTestUsingAnnotation.java in /work/testng/src.

  • Add check strategies, testPrintMessage() and testSalutationMessage(), and initEnvironmentTest(), to your check class.

  • Add attribute dependsOnMethods = {“initEnvironmentTest”} to the @Check annotation of testSalutationMessage() technique.

  • Create testng.xml

=>Compile the MessageUtil, Check case courses utilizing javac.

=>Now, run the testng.xml, which is able to run the testSalutationMessage() technique solely after the execution of initEnvironmentTest() technique.

Instance Utilizing dependsOnGroups

  • Create a java class to be examined, say, MessageUtil.java

  • Create a java check class, say, DependencyTestUsingAnnotation.java.

  • Add check strategies, testPrintMessage() testSalutationMessage(), and initEnvironmentTest() to your check class, and add them to the group “init”.

  • Add the attribute dependsOnGroups = {“init.*”} to the @Check annotation of testSalutationMessage() technique.

  • Create testng.xml

=>Compile the MessageUtil, Check case courses utilizing javac.

=>Now, run the testng.xml, which is able to run the testSalutationMessage() technique solely after the execution of initEnvironmentTest() technique.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com