ShaftHQ / SHAFT_ENGINE

SHAFT is a unified test automation engine for web, mobile, API, CLI, database, and desktop e2e testing. Powered by best-in-class frameworks, SHAFT provides a wizard-like syntax to drive your automation efficiently, maximize your ROI, and minimize your learning curve with no limitations! Stop reinventing the wheel! Upgrade now!
https://shafthq.github.io/
MIT License
330 stars 127 forks source link

[Bug]: cant run specific testng group using mvn test command #1724

Closed themosaeed closed 1 month ago

themosaeed commented 1 month ago

Describe the bug

when I try to assign testing groups to some test cases and try to run this group using the command mvn test -Dgroups={group name} execution failed with the following error Cannot invoke "com.shaft.driver.SHAFT$GUI$WebDriver.assertThat()" because "this.driver" is null

Link to SHAFT_Engine Console logs

https://gist.github.com/themosaeed/de36ab0c21bc198e7fe65b5d9053de61

Link to SHAFT_Engine Extent Report HTML

(https://gist.github.com/themosaeed/b906e17e3f8ef1011c0c257e30879930

Environment

  1. SHAFT_Engine version that exhibits the issue (Note: We support only the latest release): latest
  2. Last SHAFT_Engine version that did not exhibit the issue (if applicable): never
  3. Desktop OS: [e.g. iOS] mac and windows
  4. Desktop Browser (if applicable): [e.g. chrome, safari] chrome , edge and firefox
  5. Desktop Browser Version (if applicable): [e.g. 22] latest
  6. Mobile Device Name (if applicable): [e.g. iPhone6]
  7. Mobile Device OS (if applicable): [e.g. iOS8.1]
  8. Mobile Device Browser or Native App:
  9. Mobile Device Browser (if applicable): [e.g. chrome, safari]
  10. Mobile Device Browser Version (if applicable): [e.g. 22]

To Reproduce

Steps to reproduce the behavior: assign a group to any test case @Test(groups = { "trail" }) try to run the test case using the following command mvn test -Dgroups=trail

Expected behavior

to run the specific test or tests assigned to this group

AhmdZanoon commented 1 month ago

@themosaeed i think you initiate driver in before method , this method must have same group name in order to be initiated before your test method

themosaeed commented 1 month ago

@zanoon2020 this works but nor it dosent read the data in the @beforeclass because it needs to have the same group. what if I need to have multiple groups ? i have only 1 before method in basetest class and 1 before class per class to grap all the needed data for all tests in the class that might have different groups

AhmdZanoon commented 1 month ago

@themosaeed groups can have multiple values , for your base test class it must have all group names you specify in order to be run before your test class @beforeClass(groups ={"smoke", "regression"})

AhmdZanoon commented 1 month ago

@themosaeed i have something in mind , please set alwaysRun = true in your base test and run again without adding group to test base

@BeforeClass(alwaysRun=true)

themosaeed commented 1 month ago

alwaysRun = true works perfectly but have to be put on the before method in base class and befroeclass in the test class. and also after method if you have

thank you @zanoon2020 for the help