How to use forTest method of net.serenitybdd.junit.runners.TestMethodAnnotations class

Best Serenity JUnit code snippet using net.serenitybdd.junit.runners.TestMethodAnnotations.forTest

Run Serenity JUnit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1package net.serenitybdd.junit.runners;
2
3import com.google.common.base.Preconditions;
4import net.thucydides.core.annotations.WithDriver;
5import org.junit.runners.model.FrameworkMethod;
6
7/**
8 * Utility class used to read Serenity annotations for a particular JUnit test.
9 * @author johnsmart
10 *
11 */
12public final class TestMethodAnnotations {
13
14    private final FrameworkMethod method;
15
16    private TestMethodAnnotations(final FrameworkMethod method) {
17        this.method = method;
18    }
19
20    public static TestMethodAnnotations forTest(final FrameworkMethod method) {
21        return new TestMethodAnnotations(method);
22    }
23
24
25    public boolean isDriverSpecified() {
26        return (method.getMethod().getAnnotation(WithDriver.class) != null);
27    }
28
29    public String specifiedDriver() {
30        Preconditions.checkArgument(isDriverSpecified() == true);
31        return (method.getMethod().getAnnotation(WithDriver.class).value());
32    }
33
34
35}
36
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Most used method in TestMethodAnnotations

Trigger forTest code on LambdaTest Cloud Grid

Execute automation tests with forTest on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)