How to run JUnit tests with tag values in Gradle?

274 views
Skip to first unread message

Shanaka Fernando

unread,
Feb 22, 2017, 10:02:12 PM2/22/17
to Serenity BDD Users Group
Has anybody tried to filter JUnit tests with Gradle before? 

I'm aware of -Dtest.single parameter however my requirement is to filter with the tag value I set with '@WithTag' annotation in my test.

Example:
@Test
@WithTag(name = "default_login")
public void validUserShouldBeAbleToLoginWithDefaultUser() {
loginSteps.user_login_with_default_user();
}

@Test
public void validUserShouldBeAbleToLoginWithAdmin() {
loginSteps.user_login_to_the_application("user", "user");
}

Could anyone help me to figure out how to run the first test by passing the tag value 'default_login' with Gradle please.

Shanaka Fernando

unread,
Feb 23, 2017, 6:55:12 AM2/23/17
to Serenity BDD Users Group
Further I could easily do this with maven but still I'm trying a way to handle the same with Gradle and really appreciate if anybody could give me an idea on this.

 mvn clean verify -Dtags="default_login"

Shanaka Fernando

unread,
Feb 27, 2017, 8:37:19 AM2/27/17
to Serenity BDD Users Group
This is just a kind follow up, as I could not find any resources out there on this topic.

If anybody has an idea, really appreciate if you could reply.

Cheers...

John Smart

unread,
Feb 27, 2017, 8:53:41 AM2/27/17
to Shanaka Fernando, Serenity BDD Users Group
gradle -Ptags="default_login" should do the trick


--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-users+unsubscribe@googlegroups.com.
To post to this group, send email to thucydides-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
___________________________________________________
John Smart | Wakaleo Consulting  |  +44 7398 832273
Making smart teams collaborate better
http://johnfergusonsmart.com  |  john....@wakaleo.com
___________________________________________________

We love breaking down silos and helping smart teams collaborate better! Ask about our tailored on-site workshops in Agile Product Planning, BDD Requirements Discovery,  BDD, TDD and Clean Coding, and Advanced BDD Test Automation.
___________________________________________________
Reply all
Reply to author
Forward
0 new messages