Tuesday, 15 May 2012

java - Continue Execution after step fails in JBehave scenario -



java - Continue Execution after step fails in JBehave scenario -

i using selenium webdriver jbehave. jbehave story contains few scenarios repetitive steps shown in below steps , have created mutual function execute them.

scenario: 25. validate column database given open application url , login username "username1" , password "password1" validate "column1" database validate "column2" database validate "column3" database logout of portal

this mutual function validate column database

@then("i validate \"$column\" database") public void validatecolumnfromdb(string column) { if(column.equals("column1")) getcolumnfromdb(propertiesconfiguration.getstring("column1")); else if(column.equals("column2")) getcolumnfromdb(propertiesconfiguration.getstring("column2")); else if (column.equals("column3")) getcolumnfromdb(propertiesconfiguration.getstring("column3")); }

i used junit errorcollector() after execution, jbehave says "all tests passed" though there failures , errorcollector() collected them. atleast jbehave should steps failed.

my question want go on execution in jbehave after validaiton of 1 of column fails (ony 1 of step mentioned in scenario).

thanks help

i cheking of columns in single step, in way:

scenario: 25. validate column database given open application url validate next columns: "column1,column2,column3" database @then("i validate next columns: \"$columns\" database") public void then_i_walidate_columns_from_databale( list<string> columns){ string columnswitherror = ""; boolean validationresult = true; for( string column : columns){ boolean validationresultofcurrentcolumn = ( null != getcolumnfromdb(column)); validationresult &= validationresultofcurrentcolumn; if( ! validationresultofcurrentcolumn ){ columnswitherror += column + " "; } } assert.asserttrue("the next columns don't pass validation: " + columnswitherror, validationresult); }

java selenium-webdriver jbehave

No comments:

Post a Comment