java - How to use function parameters if function have @Test annotation? -


is there way use parameters in function if function has @test annotation. have function below:

@test(@test(priority=1, alwaysrun =true)) public void home_page_flextronics(string susername, string spassword) throws filenotfoundexception      {         commonfunctions.launchapplication();                     commonfunctions.login(susername, spassword);             commonfunctions.clickonmodule("customers");          commonfunctions.clickonhome();         commonfunctions.logout();            } 

however when trying run above code giving me error:

method home_page_flextronics requires 2 parameters 0 supplied in @test annotation.

if remove parameters , use hardcoded values, working fine , requirement of framework. have gone through other solutions suggest use @parameter annotation or data provider. don't want use want take testdata excel sheet. please let me know if there other way present handle this. in advance.

you take @ junit theories (introduction)

import org.junit.experimental.theories.datapoints; import org.junit.experimental.theories.theories; import org.junit.experimental.theories.theory; import org.junit.runner.runwith;  import static org.junit.assert.asserttrue;  @runwith(theories.class) public class additionwiththeoriestest {    @datapoints   public static int[] positiveintegers() {        return new int[]{                         1, 10, 1234567};   }    @theory   public void a_plus_b_is_greater_than_a_and_greater_than_b(integer a, integer b) {       asserttrue(a + b > a);       asserttrue(a + b > b);   } } 

this way can pass parameters test. in method annotated datapoints you'll need fetch excell data , return it.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -