title: WebDriver + TestNG - How to handle test results
body: <p>I'm quite new to WebDriver and TestNG framework. I've started with a project that does a regression test of an e-commerce website. I'm done with the login and registration and so on. But there is something that I don't quite understand.</p>
  
  <p>Example, I have this easy code that searches for a product.</p>
  
  <pre><code>driver.get(url + "/k/k.aspx");
  driver.findElement(By.id("q")).clear();
  driver.findElement(By.id("q")).sendKeys("xxxx"); //TODO: Make this dynamic
  driver.findElement(By.cssSelector("input.submit")).click();
  </code></pre>
  
  <p>Now I want to check if xxxx is represented on the page. This can be done with</p>
  
  <pre><code>webdriver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*xxxxxx[\\s\\S]*$")
  </code></pre>
  
  <p>I store this in a Boolean and check if its true or false. </p>
  
  <p>Now to the question, based on this Boolean value I want to say that the test result is success or fail. How can I do that? What triggers a testNG test to fail?</p>