在硒测试中无法调用自定义注释

时间:2018-11-16 06:50:40

标签: java selenium junit annotations apache-poi

无法在硒测试中调用自定义注释 我正在编写一个Apache poi硒测试单元- 为了避免@RunWith我尝试了myown注释

public class MyTest extends OtherTest {
    String a ;
    String b;
    String c;
    String d;

   @testDataProvider(name = "abc")
    public static Object[][] fetchClass(){
        Object[][] ar = excel.getar("abc");
        return (ar);
    }

    @testDataProviderTest(dataProvider = "abc")
    @Test
    public void test1() {
        System.out.println(a);
    }

testDataProvider的自定义注释类,我试图在下面的Custom注释中使用相同的testng DataProvider。

 @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface testDataProvider {
    public String name() default "";
    boolean parallel() default false;
    int[] indices() default {};
}

testDataPrviderTest的自定义注释

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD,ElementType.CONSTRUCTOR,ElementType.TYPE})
public @interface testDataProviderTest {
    public String[] groups() default {};
    public boolean enabled() default true;
    @Deprecated
    public String[] parameters() default {};
    public String[] dependsOnGroups() default {};
    public String[] dependsOnMethods() default {};
    public long timeOut() default 0;
    public long invocationTimeOut() default 0;
    public int invocationCount() default 1;
    public int threadPoolSize() default 0;
    public int successPercentage() default 100;
    public String dataProvider() default "";
    public Class<?> dataProviderClass() default Object.class;
    public boolean alwaysRun() default false;
    public String description() default "";
    public Class[] expectedExceptions() default {};
    public String expectedExceptionsMessageRegExp() default ".*";
    public String suiteName() default "";
    public String testName() default "";
    public boolean sequential() default false;
    public boolean singleThreaded() default false;
    public Class retryAnalyzer() default Class.class;
    public boolean skipFailedInvocations() default false;
    public boolean ignoreMissingDependencies() default false;
    int priority() default 0;

}

我避免像使用Before方法那样使用@RunWith来获取Excel工作表的路径。

0 个答案:

没有答案