Interface Automation test phpunit-Framework Code Development 1

Source: Internet
Author: User

After the previous architectural design, we began to write code, because the code is more involved, so will be explained several times.

Take a look at the whole structure diagram first

650) this.width=650; "src=" http://p1.pstatp.com/large/46e0000457d946e4326f "alt=" interface Automation test phpunit-Framework Code Development 1 "style=" border-style:none;margin:10px auto; "/>

Today, let's take a look at the writing in the TestCase file. Here we take the previous ancient history interface as an example.

lhl_test.php content is as follows:

<?php

Code get click Link Join QQ Group 522720170:https://jq.qq.com/?_wv=1027&k=5C08ATe

Introduce some of the necessary documents, leave it alone, and you'll talk later.

Require_once (".. /commons/require.php ");

Use Phpunitframeworktestcase;

Class Lhltest extends TestCase

{

Test cases must start with test, or phpunit do not recognize

Public Function Testlhl ()

{

Select a running environment. The host is configured in the file to read the contents of the file directly.

$RC =new readconfig ();

$url = $RC->get_host ("online");

echo $url;

Stitching the complete request string

$get _params= "date=2017-11-11&key= fill in your Application key";

$url = $url. "?". $get _params;

$content =transfer::get ($url);

Encodes the returned JSON result, which translates to objects that can be recognized by PHP for later use

$data = Json_decode ($content, true);

Print_r ($data);

if (Is_null ($data) ==false)

{

Assertion if the returned Error_code is 0 indicating that the interface succeeded

$this->assertequals (' 0 ', $data [' Error_code '], "failed");

Print ("successed");

}

}

}

?>


This article is from the "Cockroach Performance automation test brand" blog, please be sure to keep this source http://xqtesting.blog.51cto.com/4626073/1982675

Interface Automation test phpunit-Framework Code Development 1

Related Article

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.