Interface Test (Java+testng+ant+jenkins) Fifth Java II

Source: Internet
Author: User
Tags testng

1, Data code separation, convenient maintenance.

The general practice is to save the data in Excel, which is read by the program.

2. Read Excel data.

The new Excel,a column in the D-Disk url,b the column-drop parameters.

  

  

New Class Redexcel

 PackageCOM.LX;ImportJava.io.File;Importjava.io.IOException;ImportJxl.*; Importjxl.read.biff.BiffException; Public classredexcel{ Public Static voidMain (string[] args)throwsbiffexception, IOException {//reading data from coordinates B1 in a documentSystem.out.println (Getexceldata ("D:\\apitest.xls", 2, 1)); }    /** Get data for Excel documents according to path and coordinates * parameter description: path (Excel document Path), x (x coordinate), y (y coordinate) **/     Public StaticString Getexceldata (String path,intXintYthrowsbiffexception, ioexception{Workbook book;        Sheet Sheet;        Cell cell1;        String str; Book= Workbook.getworkbook (NewFile (path)); Sheet= Book.getsheet (0); Cell1= Sheet.getcell (X-1, y-1); STR=cell1.getcontents (); returnstr; }}

3, read the data, send the request

  

  @Test  publicvoidthrows  biffexception, IOException {      System.out.println ("test1");       = Redexcel.getexceldata ("D:\\a.xls", 1, 1);       = Redexcel.getexceldata ("D:\\a.xls", 2, 1);       =    httprequest.sendget (URL, data);      System.out.println (s);      Asserttrue (S.indexof ("and")!=-1);  }

Interface Test (Java+testng+ant+jenkins) Fifth Java II

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.