Selenium automation-java-encapsulation assertions, selenium-java-

Source: Internet
Author: User

Selenium automation-java-encapsulation assertions, selenium-java-

Encapsulated assertions.

1 package com. baidu. www; 2 3 import org. testng. assert; 4/* 5 * encapsulate assertion 6 */7 public class assertion {8 static boolean flog = true; 9 10 public static void verifyassert (Object actual, Object expected) {11 try {12 Assert. assertEquals (actual, expected); 13} catch (Error e) {14 // TODO: handle exception15 flog = false; 16} 17} 18 19 public static void verifyassert (Object actual, object expected, String message) {20 try {21 Assert. assertEquals (actual, expected, message); 22} catch (Error e) {23 // TODO: handle exception24 flog = false; 25} 26 27} 28}

Call method, Judge error, continue execution

1 @ Test 2 public void test1 () {3 System. out. println ("Test Case 1"); 4 int actual; 5 int expected; 6 actual = 1; 7 expected = 2; 8 assertion. flog = true; 9 for (int I = 0; I <3; I ++) {10 System. out. println ("assertions start 1"); 11 assertion. verifyassert (I, expected, "test whether the connections are the same"); 12 System. out. println ("assertion ended"); 13 // The result is tur; to modify 14} 15 Assert. assertTrue (assertion. flog); // The result is changed to flog, error

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.