Failed test is not failing in html test reports, its failing only in eclipse console

Hello
I am comparing the text entered in the user name field with the text i have mention below, and the text should fail in the html report generated by appium. But this is not the actual case the test is failing in eclipse console which is the desired behaviour but passing in the appium html report.
Please let me know what have i missed?

WebElement userName = driver.findElement(By.id(“custom_onboard_edittext_txt”));
driver.getKeyboard().sendKeys(“BABita @%^$&$* 1234567890 qwerty )(&&^^%%% ASDFGHJK");
assertEquals(userName.getText(), "BABita @%^$&$
1234567890 qwerty )(”);

You need to catch the assertions who have failed and add them to the report

the way it’s usually done is by using the testing framework configuration methods to run a step after each test and check to see if there were an assertion that needs to be present in the report

e.g -

@AfterMethod
//runs after each @Test Method, checks if the test throw an error of type assertion and adds
the assertion content to the report along with a screen shot from the device
    public void addAssertionsToReport(ITestResult testResult)
    {
        Throwable throwable = testResult.getThrowable();
        if (throwable!=null && throwable instanceof AssertionError && driver!=null)
            driver.executeScript("client:client.report('Assertion failed : " + throwable.getMessage() + "',false)");

    }

This method needs to be present in the class that runs the test, or a member of a super class (e.g - LoginTests extends TestBase)

What is the method for junit?

Something like

 public static class WatchmanTest {
  private static String watchedLog;

  @Rule
  public TestWatcher watchman= new TestWatcher() {
      @Override
      protected void failed(Throwable e, Description description) {
          watchedLog+= description + "\n";
          driver.executeScript("client:client.setTestStatus(true,'"+watchedLog + "')");
      }

      @Override
      protected void succeeded(Description description) {
          watchedLog+= description + " " + "success!\n";
          driver.executeScript("client:client.setTestStatus(false,'"+watchedLog + "')");



         }
     };

  @Test
  public void fails() {
      fail();
  }

  @Test
  public void succeeds() {
     }
 }
1 Like

I’m having the problem with no assertion, no eclipse failed and no supporting report.

I can’t even tell the language :slight_smile:

You could place a breakpoint and debug the line that fails… I might got the test rules wrong for your version also…

1 Like

[Step Eclipse]

public void checkdeletemessage(String resultado) {
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(“feedback_message”)));
WebElement mensagem = driver.findElement(By.xpath("//*[@text=‘Meio de pagamento excluído com sucesso!’]"));
assertEquals(mensagem.getText(), resultado);

}

[Step Appium Studio]

Note:

The positive message has the same id, the negative message.

The appium is comparing the ids, and the eclipse can identify the divergence of the message.

did you add the commands with the test rule?

can you see if the test rule is running or not by debugging the test (place a break point in the failed & success functions)

the code that should fail the test needs to run… (executeScript…)