java - TestNG try/catch not working properly -


i working on test automation framework built. framework reads test data excel file , uses selenium webdriver control browser , perform tests.

i adding functionality framework adding testng class reads data csv file. functions in current framework use try/catch. when call these functions testng class, testng test passed, no matter what.

for example, current framework;

    if (entervalueinbox.length() >= 1) {         try {             browseractions.typevalueintextbox(mydriver, entervalueinbox);         } catch (exception e) {             system.out.println("entervalueinbox failed");         }     } 

this if statement inside function. doesn't matter whether functions works or not, pass in testng. if selenium can not find element example.

how can work around this? have change try/catch?

edit: example same function. function consists of several if statements 2 showing here. have same signature, if statement try/catch inside. worth mentioning, function/class calling not testng class. built testng class, , calling non-testng class->method.

   if (backspaceintextbox.length() > 1) {         try {             wa.handleselenesecommand(mydriver, properties.time_to_wait,                     "niet gelukt");             browseractions.dobackspaceintextbox(mydriver,                     backspaceintextbox);         } catch (exception e) {             system.out.println("could not backspace");         }     } 

your tests passing because test function completes

  • without assertion failures
  • without exception thrown test method

in case, should 1 of

  • do not catch exceptions @ all. declare test methods throw exceptions
  • catch exception , fail test (assert.fail)

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -