Vous êtes sur la page 1sur 12

Yury Makedonov p.

1 of 12

Functional Testing of Web Services

Yury Makedonov, CGI

2004 International Quality Conference, Toronto, Ontario, Canada


© Copyright 2004 – CGI Group Inc. September 22, 2003
September 22, 2004 Functional Testing of Web Services, QAI Conference 1

Agenda
¾ Why we are getting more and more
web services testing

¾ What are web services

¾ What is XML

¾ How to test web services


¾ Test Approach

¾ Tools

¾ Summary

¾ Q&A

¾ Intended audience:
Testers without development background

September 22, 2004 Functional Testing of Web Services, QAI Conference 2

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 2 of 12

Introduction

¾ Webservices have no GUI. Typically this type of


testing is performed by developers.
¾ Independent testing teams started getting more and
more webservices testing projects
¾ Why are webservices so special?

September 22, 2004 Functional Testing of Web Services, QAI Conference 3

Why web services?

¾ Web services are a simple interface using HTTP


protocol.
¾ Web services can be:
¾ developed by one company,
¾ used by another company, and
¾ hosted by a third company.

¾ Such involvement of several companies is a


business cases for independent testing of web
services.

September 22, 2004 Functional Testing of Web Services, QAI Conference 4

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 3 of 12

What are web services?

¾ What’s in the name Web Services?


¾ Web means HTTP protocol,
¾ Services means request – response.

¾ Web services is a stateless protocol


¾ we send a request,
¾ we receive a response,
¾ we are finished.

¾ Why is this so important from testing point of view?


¾ Because we can prepare independent test cases that are
separate files. This makes our test approach relatively
simple.

September 22, 2004 Functional Testing of Web Services, QAI Conference 5

XML

¾ Web services use XML encoded data (XML files) for


communication.
¾ What is XML?
¾ XML file is a text file that uses tags, similar to HTML
tags, to describe data.
¾ Why is this so important from testing point of view?
¾ Because our test cases (files) should be in XML format.

September 22, 2004 Functional Testing of Web Services, QAI Conference 6

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 4 of 12

Examples of XML tags

¾ Examples of XML tags from auto insurance:


¾ <DateFirstLicensed>1990-06-12</DateFirstLicensed>
¾ <DateOfBirth>1969-07-21</DateOfBirth>
¾ <DriverTraining>Y</DriverTraining>
…………………………………………
These samples are pretty intuitive.

¾ Examples of blank XML tags (value not specified):


¾ <Company/>
¾ <Department></Department>

September 22, 2004 Functional Testing of Web Services, QAI Conference 7

More XML details – document definition

¾ Every XML document has to have a certain structure


and certain values of parameters.
¾ Special files, defining XML documents, are used.
Two major types are:
¾ DTD (Document Type Definition) – flat text file,
¾ XSD (XML Schema Definition) – XML based definition.

September 22, 2004 Functional Testing of Web Services, QAI Conference 8

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 5 of 12

Sample – “Document Type Definition”

¾ Note.xml:
¾ <?xml version="1.0"?>
¾ <!DOCTYPE note SYSTEM "note.dtd">
¾ <note>
¾ <to>Tove</to>
¾ <from>Jani</from>
¾ <body>Don't forget me this weekend</body>
¾ </note>

¾ Note.dtd:
¾ <!ELEMENT note (to,from,body)>
¾ <!ELEMENT to (#PCDATA)>
¾ <!ELEMENT from (#PCDATA)>
¾ <!ELEMENT body (#PCDATA)>
September 22, 2004 Functional Testing of Web Services, QAI Conference 9

Sample – “Schema Definition” – Document

¾ Note.xml:
¾ <?xml version="1.0" encoding="UTF-8"?>
¾ <ServiceAddressRequest
xmlns:xsi="http://www.w3.org/2001/"
xsi:noNamespaceSchemaLocation="Note.xsd">
¾ <note>
¾ <to>Tove</to>
¾ <from>Jani</from>
¾ <body>Don't forget me this weekend</body>
¾ </note>

September 22, 2004 Functional Testing of Web Services, QAI Conference 10

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 6 of 12

Sample – “Schema Definition” – Schema


¾ Note.xsd:
¾ <?xml version="1.0"?>
¾ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
¾. . . . . . . . .. . . .
¾ <xs:element name="note">
¾ <xs:complexType>
¾ <xs:sequence>
¾ <xs:element name="to" type="xs:string"/>
¾ <xs:element name="from" type="xs:string"/>
¾ <xs:element name="body" type="xs:string"/>
¾ </xs:sequence>
¾ </xs:complexType>
¾ </xs:element>
¾ </xs:schema>
September 22, 2004 Functional Testing of Web Services, QAI Conference 11

SOAP

¾ SOAP = Simple Object Access Protocol:


¾ A SOAP envelope:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<gs:doGoogleSearch xmlns:gs="urn:GoogleSearch">
........
<start>0</start>
<maxResults>10</maxResults>
<filter>true</filter>
.........
</soap:Body>
</soap:Envelope>>

September 22, 2004 Functional Testing of Web Services, QAI Conference 12

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 7 of 12

How to learn XML


¾ Do we need to know all intricacies of XML, DTD, and
XML schemas to start testing of web services?
¾ No!
¾ With basic XML principles, described above, you can
start development of XML test data files!
¾ I recommend an approach for XML learning:
¾ Get sample XML files with corresponding DTD or XSD files
for your new webservices project.
¾ Go through major elements and try matching definitions from
DTD/XSD and corresponding XML data.
¾ Use web sites (e.g. http://www.w3schools.com) or XML books
as additional sources of information.

September 22, 2004 Functional Testing of Web Services, QAI Conference 13

Testing web services – Test Approach

¾ When testing webservices we use the same approach


as for any other testing project:
¾ identify requirements,
¾ Prepare high level test cases,
¾ Document detailed test cases, etc.
¾ What would be an outcome of a test planning phase:
¾ a set of test cases described in plain English language and
based on a requirements document,
¾ a corresponding set of XML files.

September 22, 2004 Functional Testing of Web Services, QAI Conference 14

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 8 of 12

Sample test case

¾ Requirement:
¾ “Location type” can be blank in a request

¾ Test case brief description:


¾ “Location type” is blank in a request

¾ XML test data file:


.......
<locationInfo>
<locationType></locationType>
<locationVal>1600</locationVal>
</locationInfo>
.......

September 22, 2004 Functional Testing of Web Services, QAI Conference 15

How to prepare XML test files

¾ How to prepare XML test files:


¾ We have to get a sample XML file from a software developer
and to enter our values of parameters.
¾ This is not so terribly different from a standard GUI testing.
¾ The only difference:
we have to enter our data into “fields” of XML document
instead of fields of GUI.

¾ We have to follow a standard testing procedure,


familiar to every black box tester and to use standard
testing techniques when testing Web Services:
¾ valid and invalid data,
¾ boundary values,
¾ equivalence partitioning, etc.

September 22, 2004 Functional Testing of Web Services, QAI Conference 16

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 9 of 12

Tools – to prepare XML test files

¾ What tools to use for XML files preparation:


¾ Whatever you have,
¾ from Notepad
¾ and Microsoft Word
¾ to XMLSpy

¾ My favorite tools are:


¾ Notepad (or TextPad for bigger files)
¾ XMLSpy

September 22, 2004 Functional Testing of Web Services, QAI Conference 17

Tools – to execute a test

¾ We have prepared a set of XML files that represent


our test cases.
¾ Next step is to process these files.
¾ To process XML files (XML requests) we need:
¾ to POST an XML file (to send it to a specific URL and port),
¾ to capture an XML response and to save it into a file.

¾ We need a tool to do this.

September 22, 2004 Functional Testing of Web Services, QAI Conference 18

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 10 of 12

Tools – to execute a test

¾ Load Testing tools


¾ Natural choice is any load testing tool, designed to handle
HTTP traffic.
¾ XMLSpy.
¾ XMLSpy can POST a SOAP document and capture a
response.
¾ Custom tools/script:
¾ A Perl script or a Java program can be developed to send a
request and to capture a response.
¾ Empirix eTest:
¾ Commercials tool to test SOAP based web services.

¾ Many more options.

September 22, 2004 Functional Testing of Web Services, QAI Conference 19

Analyzing results

¾ After we have XML response files we have to


compare them against expected results, described in
our test cases.
¾ Typically we have to verify values in some specified
fields.
¾ That task is not so different from a standard GUI
testing.

September 22, 2004 Functional Testing of Web Services, QAI Conference 20

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 11 of 12

Regression testing

¾ In case of a regression testing we can use a less time


consuming approach.
¾ We can automatically compare a new set of XML
responses to a previous set, using:
¾ WinDiff.exe,
¾ XMLSpy,
¾ MS Windows commands: “Comp” or “fc”

September 22, 2004 Functional Testing of Web Services, QAI Conference 21

Summary

¾ Testing of web services is not so different from a


standard GUI testing,
¾ New skills to learn are relatively simple (half a day or a
day to learn),
¾ Typical testing team already has most skills and
knowledge required for this type of testing,
¾ Testing web services can bring additional job and
visibility to an independent test team.
¾ Let’s leverage our skills and knowledge to a new field.
¾ Let’s test web services.

September 22, 2004 Functional Testing of Web Services, QAI Conference 22

International Quality Conference, Toronto, Ontario, Canada September 22, 2004


Yury Makedonov p. 12 of 12

Contact Information

¾ Yury Makedonov
(416) 481-8685
ivm@ivm-s.com
http://www.ivm-s.com

September 22, 2004 Functional Testing of Web Services, QAI Conference 23

References

¾ The above examples are from:


CGI projects
http://www.w3schools.com,
http://www.intertwingly.net/stories/2002/12/20/sbe.html
¾ You can find more information on XML on these and
many other web sites.

September 22, 2004 Functional Testing of Web Services, QAI Conference 24

International Quality Conference, Toronto, Ontario, Canada September 22, 2004

Vous aimerez peut-être aussi