Service-side interface Automation testing tools Daquan and adaptation environment analysis

Source: Internet
Author: User
Tags data structures message queue testng
In the Internet era, the service-side testing has become an important product assurance means, each of the company implemented methods and technology is also different, this article we will discuss.

Internet Server Interface Automation is a part of each company needs a business, how to complete the interface test quickly and efficiently.

To help you achieve efficient interface testing as a starting point, this article contains my Internet interface testing in the field of some of the methods and ideas, I hope you discuss and share, including but not limited to:

Internet server Interface Test introduction;

Interface test commonly used tools, platforms, frameworks;

Some problems and practices of interface testing.

The following figure is the classic test pyramid, the service interface test in the middle, connecting, this shows its importance.

   

Introduction to Internet service-side interface testing

There are many tools on the market that support interface testing to improve test efficiency. But do you think it's possible for you to complete 100 interface test tasks in a day?

You might say there are tools, but not all tools can support you in this task. The following figure is a few of the tools I selected:

1. Fiddler

Fiddler is an HTTP Protocol debugging Agent tool that is used for both Web and mobile testing, and also supports interface testing. I'll introduce you later.

2. Postman

It is a plug-in developed by Google, installed in the Chrome browser, can support different interface test requests, can manage test suites and automated operation. The weakness is that the automation assertion is not powerful and does not perform continuous integration testing with Jenkins, the Code management Library.

However, it is definitely a good semi-manual, semi-automated test tool. I typically write automated interface test cases that open postman for auxiliary testing and Debug, as described below.

3. Wireshak

This is a grab package tool that supports TCP, UDP, HTTP. If you do the underlying network data test, it is generally needed, but as an interface test, it is a bit unfriendly. Because refreshing the data is too fast, it is not good to locate the corresponding interface for each operation. Therefore, there is not much to introduce the tool here.

4. Soupui

 

This is an open source free version and enterprise pay version of the software. In the foreign interface test, the use of more. The tool supports both interface Automation testing and interface performance testing, as well as continuous integration testing with Jenkins. Learn about it, you can download a community free version, do a Demo try.

5. Java code to do interface test

 

Why use code to do interface Automation testing. Some tool features are limited, many companies need some specific features, tools do not support, have to use code to develop. The general use of Java for automated testing, mainly using the Httpclient.jar package, and then using JUnit or TestNG, such as unit testing tools for the development of test cases, and then create a job on Jenkins, for continuous integration testing.

6. Python code to do interface testing

 

Like Java, the interface test with Python makes use of a powerful third-party library requests, which makes it easy to create interface automation use cases. The unit test framework under Python is generally used unittest. Generate test Report, general select htmltestrunner.py. Similarly, continuous integration testing can be done in conjunction with Jenkins.

7. LoadRunner

Do not assume that LoadRunner can only do performance testing, it can also do interface automation and interface pressure testing. It's just that many of us don't use LoadRunner's functions to design interface test cases.

8. JMeter

JMeter, like LoadRunner, are famous for their performance tests, and generally use JMeter to do interface performance testing. For example Java+jmeter+ant+jenkins do interface performance monitoring tests. JMeter How to do interface testing, you can check the official documents and CSDN Blog column "JMeter performance test".

It says so many tools, basically covering the interface function test, interface Automation test, interface performance test. In this case, it is recommended that a performance test tool locust in the Python language. Own Baidu and installed, very simple Web interface, as a lightweight test tool for the process, feel very good.

Server-side testing should also have the ability to have some basic computer knowledge, such as the following areas of knowledge.

operating systems and networks

The biggest application scenario in the Internet is high concurrency, high availability, high-performance online services, and doing this kind of system actually tests our understanding of the operating system and the network. Any system that runs on top of the operating system and runs on the network, including distributed systems, requires deep attainments in both the operating system and the network, especially high concurrency and high performance.

If you know nothing about operating system principles, it's hard to understand what concurrency and locks are, it's hard to understand what metrics to use for high performance, and how to achieve high concurrency, high availability, and high performance.

For the operating system, we must understand the CPU's multicore architecture, memory paging and caching technology, disk IO suboptimal and Nic Io, and to understand how the computer works, the performance that the service can output is roughly evaluated based on these metrics.

For the network, you must understand the theoretically defined 7-tier model and understand the three-time handshake of TCP/IP. In addition, we use the HTTP protocol of the application layer in the Distributed service architecture, so we need to have a deep understanding of the HTTP protocol.

algorithms and data Structures

Application level of small partners may be less application of algorithms and data structures, even if the application is relatively simple, but the ability of the algorithm represents a person's logical thinking and thinking ability, can be a variety of basic algorithms to understand the IQ of people will not be low, able to write a good program of people logical thinking must be strong.

Usually in the interview with the small partner, I will examine whether he will be advanced algorithms, such as recursion, pruning, greed, dynamic planning. Think about it, you will know, the dynamic planning of the person, he is not diligent is smart, no matter what, you have to admit his impulse.

Line High concurrency service direction

Line high concurrency service is a strong demand, no matter what kind of application and website you develop, online service is necessary, with the service has the function, only have the product, I also mainly engaged in the Internet back-up service design and implementation.

To solve the high concurrency service is not so difficult, these senior concurrent service technology stack has no threshold, as long as the cost of investment, to build a scalable service is not a problem, how much TPS is not a problem, the core idea is "divide and conquer, big and small, and the".

We use the cache anti-read, message queue Anti-write, database Library sub-table, cache shards, application layer scaling, reduce competition, 7-tier load balancing, three or four-tier load balancing, and so on, CDN, DNS rotation, and so on, all of these are "divide and conquer" the idea.

Big Data Direction

Big data is the direction of the recent fire, large and small companies are using big data technology. Big companies use big data analytics to analyze business models from a multitude of data and derive valuable results to help companies make market and sales strategies, most of which use big data-reporting and wind-control.

All of the big data technologies are based on three papers from Mapreduce, GFS, and Bigtable, and are recommended to read these papers:

mapreduce:simplifed Data processing on Large Clusters

The Google File System

BIGTABLE:A distributed Storage System for structured Data

Understanding these basic technical principles, and then learning Hadoop, HBase, Storm, Spark, Cassandra, MongoDB, ES, and so on are not problems.

   

interface Testing common tools, platforms, frameworks

Automated testing can quickly and automatically complete a large number of test cases, save a huge cost of manual testing, and require people with professional development skills to complete development, and a lot of time to maintain (in the case of frequent changes in requirements), so most people with good development skills are not very willing to write automated use cases. However, due to the rapid growth of software scale, the gradual scarcity of human resources, automated testing is imperative.

Here are my top 8 Java test tools and frameworks.

1. Arquillian

Arquillian is a highly innovative and extensible test platform based on the JVM, allowing Java developers to easily create automated integration, functionality, and acceptance testing. Arquillian allows tests to be performed at run time. Can be used to manage the life cycle of single or multiple containers, bundling test cases, dependent classes, and resources. It is also capable of deploying archiving into containers, performing tests in containers, capturing results, and creating reports. It integrates common test frameworks such as JUnit 4, TestNG 5, and allows you to publish tests using existing Ides, and is designed to run ANT and Maven test plug-ins because of their modular design.

2. JTest

JTest, also known as the "Parasoft JTest", is an automated Java software testing and static analysis software introduced by Parasoft company. Jtest includes features such as generation and execution in unit test cases, static code analysis, static analysis of data flow, metric analysis, regression testing, and runtime error detection. In addition, it has the ability to automate peer code review processes and run-time error detection, such as race conditions, exceptions, resource and memory leaks, and security vulnerability attacks.

3. The Grinder

The Grinder is a Java load test framework that runs simply, and its distributed testing employs many load-injection machines. You can load test as long as you have a Java api,the Grinder. This includes HTTP WEB servers, SOAP and REST WEB servers, application servers, and test scripts written in powerful Jython and Clojure languages that contain custom protocols.

The Grinder GUI console allows monitoring and control of multiple load syringes and automatically manages client connections and Cookies, SSL, Agent-aware, and throttling connections. The Grinder is free under the BSD-style open source license. Official website: Downloading the Grinder

4. TestNG

TestNG is a test framework designed for the Java programming language, inspired by JUnit and NUnit. TestNG can cover a wider range of test types, such as units, functionality, end-to-end, and integration. It also has new features that make it more powerful and easier to use, such as annotations, running tests with various strategies for large thread pools, multithreaded code testing, flexible test configurations, parameterized data-driven test support, and more. TestNG supports a wide variety of tools and plugins such as Eclipse, Idea, Maven, and more.

5. JUnit

JUnit is a unit test framework designed for the Java programming language. JUnit has played an important role in the development of a test-driven development framework. It is one of the constituent members of the unit testing framework family that is now collectively referred to as XUnit, originating from Sunit. At compile time, JUnit can be connected as a JAR for writing repeatable tests.

6. Powermock

Powermock is a Java framework that supports unit test source code. Although Powermock can be used as a Mocking framework, for example, as an extension of Mockito and EasyMock, it has more power. Powermock uses a custom class loader and bytecode manipulator to ensure static method simulations, static initialization deletions, function constructs, final classes and methods, and private methods. Its main purpose is to extend the existing API with minimal methods and annotations for additional functionality.

7. Cucumber

Cucumber is an open source tool for implementing the executable specification (executable specifications) in BDD mode, but its mission is not limited to automated acceptance testing, but it is more important to build a unified communication base between team members (feature Document), standardize the exchange of terms (Domain specific Language), and improve the efficiency and effectiveness of each stakeholder (business stakeholders) communication to achieve the ultimate goal of improving product quality and making products that customers expect.

8. Python unittest

The Python unit test framework, UnitTest, is based on the popular unit test framework JUnit Design in Java, which is powerful and flexible, and mastering unittest is simple for people familiar with JUnit.

UnitTest involves more knowledge points, but only a part of the core, this article will introduce its core and basic content.

Similar to JUnit, use UnitTest to write the unit test code for Python, including the following steps:

Write a Python class that inherits the TestCase class in the UnitTest module, which is a test class.

In the test class written above, define the test method (this is referred to as the test case), the method name of each method is required to begin with test, no additional parameters. Calling the test code in the test method, verifying the test results, provides a number of standard validation methods in the TestCase class, such as the most common assertequal.

Executes Unittest.main (), which is responsible for running the test, which instantiates all TestCase subclasses and runs all of the methods that begin with test.

The following is a diagram of the Python unittest test case execution.

Let's look at some examples below and write the following Python file.

(1) Manual loading of batch use cases.

Import Unittestclass Testone (unittest. TestCase):    def setUp (self):        print ' \ncases before '        P     def Test_add (self):         ' test Add method '        print ' Add ... '        a = 3 + 4        B = 7        self.asserte Qual (A, b)    def test_sub (self):         ' Test sub method '         print ' Sub ... '        a = 10-5        B = 5        SELF.A Ssertequal (A, b)    def TearDown (self):        print ' case after '       &NB Sp;passif __name__ = = ' __main__ ':    # 1, construct use case set    suite = UnitTest.
 TestSuite ()    # 2, the order of execution is the load order: Execute the test_sub first, then execute Test_add    suite.addtest (Testone ("Test_sub"))    suite.addtest (TEstone ("Test_add"))    # 3, Instantiate runner class    runner = UnitTest. Texttestrunner ()    # 4, execute test    runner.run (suite)

(2) Automatic loading of batch use cases.

Import Unittestimport osclass testone (unittest. TestCase):    def setUp (self):        print ' \ncases before '        P     def Test_add (self):         ' test Add method '        print ' Add ... '        a = 3 + 4        B = 7        self.asserte Qual (A, b)    def test_sub (self):         ' Test sub method '         print ' Sub ... '        a = 10-5        B = 5        SELF.A Ssertequal (A, b)    def TearDown (self):        print ' case after '       &NB Sp;passif __name__ = = ' __main__ ':    # 1, set the directory for the case to be executed    test_dir = Os.path.join (OS.GETCWD ())   &N bsp;# 2. Automatically searches CAs in the specified directory, constructs the test set, and the order of execution is the naming order: Execute Test_add First, then execute test_sub    discover = unittest.defAulttestloader.discover (Test_dir, pattern= ' test_*.py ')    # instantiation Texttestrunner class    runner = UnitTest. Texttestrunner ()    # run the test suite with the Run () method (that is, run all the use cases in the test suite)    runner.run (Discover)
   

some problems and practices of interface testing

Taking TestNG as an example, it is a test framework built on the idea of JUnit and NUnit to use annotations to harden the test function. The TestNG design covers all types of testing, such as units, functions, end-to-end, integration, etc. Before learning TestNG, you need to learn the programming language Java, configure the local JDK environment (JDK1.5 version or above), and install the Java Development Tools Eclipse.

Next, we will learn TestNG together.

1. Install TestNG in Eclipse.

Open Eclipse Help, MarketPlace, enter TestNG search in the search box, and then install the TestNG plugin.

2. After successful installation, right-click on the project's package to see the Create TestNG class TestNG.

Here you can check the TestNG annotation method, the main annotation methods are:

@BeforeSuite: The method that is annotated will run the method before all tests are run.

@AfterSuite: The method that is annotated will run the method after all tests have been run.

@BeforeTest: The method that is annotated will run before the test runs.

@AfterTest: The method that is annotated will run after the test is run.

@BeforeClass: The method that is annotated will run before the first test method call of the current class.

@AfterClass: The method that is annotated will run after all test method invocations of the current class.

@BeforeMethod: The method that is annotated will run before each test method call.

@AfterMethod: The method that is annotated will run after each test method call.

@DataProvider: A test method that marks a method that provides data.

Now that the environment is set up, you can start writing the test case.

3. Start with a simple test case, with the following code:

Package Com.pingan.ff.zijin;import Org.testng.annotations.test;import Org.testng.annotations.dataprovider;import Org.testng.annotations.beforetest;import Org.testng.annotations.aftertest;public class NewTest {@Test (dataProvider  = "DP") public void F (Integer N, String s) {
 System.out.println ("The first parameter is" +n+ ", the second argument is" +s);
 } @DataProvider public
 object[][] DP () {return new object[][] {new object[] {1, "a"}, new object[] {2 , "B"},
 };
 } @BeforeTest public
 void Beforetest () {
 System.out.println ("------------start Test------------");
 } @AfterTest public
 void Aftertest () {
 System.out.println ("------------End Test------------");
 }
}

Right-click Run as, TestNG Test, after running the results as shown in the following figure.

From the test results you can see that the order of execution is beforetest (), test (), Aftertest (), and the test () method receives the parameters from the Dataprovider DP. As shown in the following figure.

Transfer from public number: CSDN Tech Headlines

Author: Softwareluke

Link Address: https://mp.weixin.qq.com/s?__biz=MzA4Mzc0NjkwNA==&mid=2650784584&idx=1&sn= 934fbedff493e622671ef93f6f97cc46&chksm= 87faaa7fb08d2369822f988cf8080f285cf2abc50524c9662d96b71140617e3235ae9955adae&mpshare=1&scene=23& srcid=0327gwqgy3j7wluuoraovahc%23rd

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.