Searched everywhere but could not find solution how to do following: As Example:
for (int i = 0; i < 5; i++) {
@Test
public void test1(){
assertThat(assertvalue 1);
}
@Test
public void test2(){
assertThat(assertvalue 2);
}
@Test
public void test3(){
assertThat(assertvalue 3);
}
}
Of course I can use dataProvider or invocationCount and do all asserts in one test case, but if one assert will fail whole test case fail. I want kind of separate one big test case for 3 small test cases Any help appreciated
Having dependencies between test cases is discouraged. You could achieve a similar result--checking each value 1-5 without short-circuiting and stopping after a failure on 2--using SoftAssert
.
SoftAssert soft = new SoftAssert();
soft.fail("Failure # 1\n");
soft.fail("Failure # 2");
soft.assertAll();
should output:
The following assertions failed:
Failure # 1
Failure # 2
I tried following code:
public class SimpleTest {
private String param = "";
public SimpleTest(String param) {
this.param = param;
}
@BeforeClass
public void beforeClass() {
System.out.println("Before SimpleTest class executed.");
}
@Test
public void testMethod1() {
System.out.println("testMethod parameter value is: " + param);
}
@Test(dependsOnMethods = "testMethod1")
public void testMethod2() {
System.out.println("testMethod parameter value is: " + param);
}
}
public class SimpleTestFactory{
@Factory
public Object[] factoryMethod() {
return new Object[] {
new SimpleTest("one"),
new SimpleTest("two")
};
}
And tried following code and it does not keep order
Add invocationCount
@Test(priority = 350, groups = "success" ,invocationCount = 10)
public void test1(){
assertThat(assertvalue 1);
}
Use "property",if you want to execute test1(),add "priority =1"
@Test
public void test1(priority =1){
System.out.println("execute frist");;
}
@Test
public void test2(priority =2){
assertThat(assertvalue 2);
}
@Test
public void test3(priority =3){
assertThat(assertvalue 3);
}
@Test
public void main() throws IOException,InterruptedException
{
FileInputStream fil = new FileInputStream(new File("C:\\Users\\V-DKumaravelu\\ECM Data\\ECM-Data-Sheet.xlsx"));
XSSFWorkbook workbook=new XSSFWorkbook(fil);
XSSFSheet sheet=workbook.getSheet("ECM");
int count=sheet.getLastRowNum();
System.out.println(count);
for (int i=1;i<=5;i++){
Snapshot sc = new Snapshot();
XSSFRow row = sheet.getRow(i);
XSSFCell cell = row.getCell(0);
String ServiceDate=cell.getStringCellValue();
System.out.println("DOSate is "+ ServiceDate);
XSSFCell cell1=row.getCell(1);
String MemberID=cell1.getStringCellValue();
System.out.println("Member "+MemberID);
XSSFCell cell2 = row.getCell(2);
String FacilityCode=cell2.getStringCellValue();
System.out.println("Facility Code "+FacilityCode);
XSSFCell cell3=row.getCell(3);
String ReleaseOfInfo=cell3.getStringCellValue();
System.out.println("ROI " + ReleaseOfInfo);
XSSFCell cell4 = row.getCell(4);
String ContactName=cell4.getStringCellValue();
System.out.println("Contact Name " + ContactName);
XSSFCell cell5=row.getCell(5);
String ContactPhoneAreaCode=cell5.getStringCellValue();
System.out.println("ContactPhoneAreaCode " + ContactPhoneAreaCode);
XSSFCell cell6 = row.getCell(6);
String ContactPhonePrefix=cell6.getStringCellValue();
System.out.println("ContactPhoePrefix " + ContactPhonePrefix);
XSSFCell cell7=row.getCell(7);
String ContactPhoneLine=cell7.getStringCellValue();
System.out.println("ContactPhoneLine " + ContactPhoneLine);
XSSFCell cell8=row.getCell(8);
String ContactPhoneExt=cell8.getStringCellValue();
System.out.println("ContactPhoneExt " + ContactPhoneExt);
XSSFCell cell9 = row.getCell(9);
String ServiceType=cell9.getStringCellValue();
System.out.println("ServiceType " + ServiceType);
XSSFCell cell10=row.getCell(10);
String ServiceLevel=cell10.getStringCellValue();
System.out.println("ServiceLevel " + ServiceLevel);
XSSFCell cell11=row.getCell(11);
String PRIS=cell11.getStringCellValue();
System.out.println("PRIS " + PRIS);
XSSFCell cell12 = row.getCell(12);
String DiagnosisCode=cell12.getStringCellValue();
System.out.println("Diagosis " + DiagnosisCode);
XSSFCell cell13=row.getCell(13);
String ProcedureCode=cell13.getStringCellValue();
System.out.println("Procedure Code " + ProcedureCode);
XSSFCell cell14=row.getCell(14);
String unitsProcedure=cell14.getStringCellValue();
System.out.println("Procedure Units " + unitsProcedure);
System.setProperty("webdriver.chrome.driver", "C:\\Users\\V-DKumaravelu\\eclipse-workspace\\ECM Portal\\driver\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://10.32.52.79:8888/ECM/clientlogin.aspx");
driver.findElement(By.id("txtUserId")).sendKeys("203861P");
driver.findElement(By.id("txtPassword")).sendKeys("RETINA01");
driver.findElement(By.id("btnLogin")).click();
driver.findElement(By.xpath("//*[@id=\'_ctl7_lbNewPA\']")).click();
driver.findElement(By.id("outpatientServices2")).click();
driver.findElement(By.id("serviceDate")).sendKeys(ServiceDate);
driver.findElement(By.id("memberID")).sendKeys(MemberID);
sc.main(driver);
driver.findElement(By.id("nextLink1")).click();
Select select = new Select(driver.findElement(By.id("facilityCode")));
select .selectByVisibleText(FacilityCode);
Select select1 = new Select(driver.findElement(By.id("releaseOfInfo")));
select1 .selectByVisibleText(ReleaseOfInfo);
driver.findElement(By.id("ContactName")).sendKeys(ContactName);
driver.findElement(By.id("ContactPhoneAreaCode")).sendKeys(ContactPhoneAreaCode);
driver.findElement(By.id("ContactPhonePrefix")).sendKeys(ContactPhonePrefix);
driver.findElement(By.id("ContactPhoneLine")).sendKeys(ContactPhoneLine);
driver.findElement(By.id("ContactPhoneExt")).sendKeys(ContactPhoneExt);
sc.main(driver);
driver.findElement(By.id("nextLink1")).click();
Select select2 = new Select(driver.findElement(By.xpath("//*[@id='serviceType']")));
select2 .selectByVisibleText(ServiceType);
Select select3 = new Select(driver.findElement(By.xpath("//*[@id=\'levelOfService\']")));
select3 .selectByVisibleText(ServiceLevel);
driver.findElement(By.id("facilityPris")).sendKeys(PRIS);
driver.findElement(By.id("diagnosisCode")).sendKeys(DiagnosisCode);
driver.findElement(By.id("addDiagnosis")).click();
driver.findElement(By.id("codeProcedure")).sendKeys(ProcedureCode);
driver.findElement(By.id("unitsProcedure")).sendKeys(unitsProcedure);
driver.findElement(By.id("addProcedure")).click();
sc.main(driver);
driver.findElement(By.id("nextLink2")).click();
driver.findElement(By.id("btnSubmit")).click();
sc.main(driver);
Assert.assertNotNull(driver.findElement(By.xpath("//*[@id=\'Table1\']/tbody/tr[5]/td[6]")),"Failed");
driver.close();
}}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.