68
Automated Testing 101 By Tabby Chapman @tabbymarie http://www.tabbychapman.c om 1

Automated testing 101

Embed Size (px)

Citation preview

Page 1: Automated testing 101

Automated Testing 101

By Tabby Chapman

@tabbymarie

http://www.tabbychapman.com

1

Page 2: Automated testing 101

About Tabby Chapman@tabbymarie

https://github.com/tabbymarie

2

Page 3: Automated testing 101

About Me

• Work for the University of California, Irvine

• Computer Scientist

• Developer Cheerleader

• Education Junkie

3

Page 4: Automated testing 101

About Me

• WordPress Skillz– Reaching my 10th anniversary developing

with WordPress – Started with 2.0.5, building a custom theme.– Ran my own company for four years– Joined Zeek for almost two years– Currently build highly specialized custom

themes and plugins for UCI.

4

Page 5: Automated testing 101

About This Presentation

• Geared towards intermediate QA testers and Developers and also for stakeholders/clients/customers

• Assumptions:– You know what WordPress is.– You know what PHP is.– You have written PHP code several times.

Successfully. Or.– You test all the things.

5

Page 6: Automated testing 101

About This Presentation

• We’ll go over– The Developer Workflow(s)– Different Types of Tests– Automated Testing– Demo– Last Words

6

Page 7: Automated testing 101

How it Currently Works

7

• Generic Software Development Lifecycle– In the dinosaur days of computers, the

majority of its users were very technical people.

– As computers became more accessible (and smaller), more and more users began to use it

– Developers needed to create a process to think outside of their own processes to accommodate non-technical users

Page 8: Automated testing 101

How it Currently Works

8

• Generic Software Development Lifecycle (cont)– Many various methods were created to

attempt to meet this need– One of these is the Software Development

Lifecycle (which was a similar process used in other disciplines)

– It is a top down approach: generic to specific– Specification, Design, Coding

Page 9: Automated testing 101

How it Currently Works

9

• Generic Software Development Lifecycle (cont)– Waterfall method is created in the ‘70s. – Structured analysis, Structured design,

Structured programming (sounds a lot like specification, design, and coding)

– Most developers tend to use Define, Design, Develop, Deploy, Maintain.

Page 10: Automated testing 101

Generic Modern Development

10

Image credit: https://www.owasp.org/images/8/84/SDLC.jpg

Page 11: Automated testing 101

Freelance Development Cycle

11

Image credit: http://mohamadsubhan.files.wordpress.com/2009/06/linear.jpg

Page 12: Automated testing 101

How it Currently Works

12

• Full Software Development Lifecycle– Many developers on teams tend to use some

form of the full development lifecycle, as there tends to need to be some form of accountability for teams.

– This includes: feasibility study, requirements definition, software design, implementation and unit testing, integration and system testing, operation and maintenance.

Page 13: Automated testing 101

Team Development Cycle

13

Image credit: http://www.softwaretestinghelp.com/unit-testing/

Page 14: Automated testing 101

Types of Tests

• Black box• White box• Unit • Integration• Functional • System• End-to-end

• Sanity• Regression• Acceptance• Load• Stress• Performance• Usability

14

Source: http://www.softwaretestinghelp.com/types-of-software-testing/

Page 15: Automated testing 101

Testing Players

15

• Quality Assurance (QA) Engineers

• Developers

• Product Owners

• Clients

• End-Users

• Other Stakeholders

Page 16: Automated testing 101

Black Box Testing?

16

Page 17: Automated testing 101

Black Box Testing

17

• Tests against requirements and functionality. Is not concerned with the internal workings.

• “If I put in 2+4, I expect 6. Does that work?”

Page 18: Automated testing 101

White Box Testing?

18

Page 19: Automated testing 101

White Box

19

• Tests against requirements and functionality with knowledge of the inner workings.

• “I know that I this system has these conditionals, so I will test all possible outcomes.”

Page 20: Automated testing 101

Unit Testing?

20

Page 21: Automated testing 101

Unit Testing

21

• Tests specific methods or functions, created by a programmer

• “Does function addTwoIntegers($num1,$num2) work as expected?”

Page 22: Automated testing 101

Integration Testing?

22

Page 23: Automated testing 101

Integration Testing

23

• Testing of whole application after new work has been integrated as they interact with the client/server

• “Does this site’s individual modules still work as expected when we put it all together?”

Page 24: Automated testing 101

Functional Testing?

24

Page 25: Automated testing 101

Functional Testing

25

• Black Box testing for specific functional requirements.

• “If I tell it to add five text inputs and send an email, does it add five inputs and send an email as expected?”

Page 26: Automated testing 101

Systems Testing

26

• Black Box Testing based on overall requirements.

• “Testing All the Things”. “Does this system meet all of the requirements as expected?”

Page 27: Automated testing 101

End-to-end Testing

27

• Similar to Systems, but also tests interaction between various elements, protocols, layers and servers.

• “Testing All the Things and Moar”. “Does this system meet all of the requirements as expected and communicate as expected to its various parts?”

Page 28: Automated testing 101

Sanity Testing

28

• A pre-test to make sure the new development is done enough to fully test.

• “Does it at least work a little bit?”

Page 29: Automated testing 101

Regression Testing

29

• Testing the whole application after something has been modified to see if something was broken as a result of the modification.

• “Does it STILL work as expected?”

Page 30: Automated testing 101

Acceptance Testing

30

• User or Customer does a round of manual tests to make sure that it meets their requirements/needs

• “Does the client think it works as expected?”

Page 31: Automated testing 101

Stress Testing

31

• Testing Performance Requirements

• “Can more than one interaction happen at the same time? How many more than one?”

Page 32: Automated testing 101

Usability Testing

32

• Testing for user-friendliness. This can be done BEFORE and AFTER development phase.

• “Yeah, it works, but is it easy to use?”

Page 33: Automated testing 101

Which testing is important for developers?

33

Page 34: Automated testing 101

Which testing is important for developers?

• Black box• White box• Unit • Integration• Functional • System• End-to-end

• Sanity• Regression• Acceptance• Load• Stress• Performance• Usability

34

Source: http://www.softwaretestinghelp.com/types-of-software-testing/

Page 35: Automated testing 101

For the Developers

35

• Which testing is important for developers?– All of them (know thy tester and thy tester’s

methods)– But especially

• Unit• Functional• Systems• Integration

Page 36: Automated testing 101

Which testing is important for testers?

36

Page 37: Automated testing 101

Which testing is important for testers?

• Black box• White box• Unit • Integration• Functional • System• End-to-end

• Sanity• Regression• Acceptance• Load• Stress• Performance• Usability

37

Source: http://www.softwaretestinghelp.com/types-of-software-testing/

Page 38: Automated testing 101

For the Testers

38

• Which testing is important for testers?– All of them (uphold they developer to unit

tests)– But especially

• Black Box• White Box• Integration• Systems• Sanity

Page 39: Automated testing 101

Which testing is important for Clients/Stakeholders?

39

Page 40: Automated testing 101

Which testing is important for Clients/Stakeholders?

• Black box• White box• Unit • Integration• Functional • System• End-to-end

• Sanity• Regression• Acceptance• Load• Stress• Performance• Usability

40

Source: http://www.softwaretestinghelp.com/types-of-software-testing/

Page 41: Automated testing 101

For the Clients/Stakeholders

41

• Which testing is important for clients/stakeholders?

• Black Box• Usability• Regression• Acceptance

Page 42: Automated testing 101

For the Clients/Stakeholders

42

• Which testing is important for clients/stakeholders?

• Black Box• Usability• Regression• Acceptance

Page 43: Automated testing 101

What does Automation of Testing mean?

43

Page 44: Automated testing 101

What does Automation of Testing mean?

44

• The traditional/easiest way to test what you develop is to make a change, and then load the app to see if that change was effective. Very Manual

• Automated Testing means to write code to test code and use testing software to test the front-end. Don’t rely on the old manual check.

Page 45: Automated testing 101

How does this apply to WordPress?

45

• WordPress utilizes a ‘test suite’ “which have multiple test cases and a library and command line tool that runs the test suite or suites” according to WordPress’ automated testing core handbook page

• For this, they use phpUnit. https://phpunit.de

Page 46: Automated testing 101

How does this apply to WordPress?

46

• PHPUnit has a series of commands that you can use to run all tests, specific tests, or specific types of tests.

Page 47: Automated testing 101

Developer Workflow

47

• When you are ready to write your plugin:– Think of the outcomes you want for your

plugin– Think of the individual methods you want to

write. Should have one output.– Write a test that checks that the output is what

you expect.– Write your method.– Lather. Rinse. Repeat.

Page 48: Automated testing 101

Developer Workflow

48

• Testing Tools

• phpUnit (official wordpress test suite)

• WordPress Developer Branch– https://make.wordpress.org/core/handbook/au

tomated-testing/

• Terminal or Editor with Testing Integrated

Page 49: Automated testing 101

Developer Workflow

49

Editors (not limited to…)– TextMate - https://macromates.com/download

• (https://github.com/meritt/phpunit-tmbundle)

– Sublime – http://www.sublimetext.com/• https://packagecontrol.io/packages/PHPUnit

– phpStorm - https://www.jetbrains.com/phpstorm/

• Supports all OS’• Phpunit built in

Page 50: Automated testing 101

Developer Workflow

50

• Put your tests IN your plugin

• /plugins/[plugindir]/tests/test-[pluginslug].php

• Add a phpunit.xml file:

• /plugins/[plugindir]/tests/phpunit.xml

Page 51: Automated testing 101

Developer Workflowphpunit.xml

51

<?xml version=“1.0” encoding=“UTF-8” ?>

<phpunit bootstrap=“vendor/autoload.php” >

<testsuites>

<testsuite>

<directory prefix="test-” suffix=".php">

./tests/

</directory>

</testsuite>

</testsuites>

</phpunit>

Page 52: Automated testing 101

Developer Workflowphpunit.xml

52

<?xml version=“1.0” encoding=“UTF-8” ?>

<phpunit bootstrap=“vendor/autoload.php” >

<testsuites>

<testsuite>

<directory prefix="test-” suffix=".php">

./tests/

</directory>

</testsuite>

</testsuites>

</phpunit>

Page 53: Automated testing 101

Developer Workflowphpunit.xml

53

<?xml version=“1.0” encoding=“UTF-8” ?>

<phpunit bootstrap=“vendor/autoload.php” >

<testsuites>

<testsuite>

<directory prefix="test-” suffix=".php">

./tests/

</directory>

</testsuite>

</testsuites>

</phpunit>

Page 54: Automated testing 101

Developer Workflowphpunit.xml

54

<?xml version=“1.0” encoding=“UTF-8” ?>

<phpunit bootstrap=“vendor/autoload.php” >

<testsuites>

<testsuite>

<directory prefix="test-” suffix=".php">

./tests/

</directory>

</testsuite>

</testsuites>

</phpunit>

Page 55: Automated testing 101

Tester Workflow

55

• When you are ready to test – Be familiar with the general requirements for

the site as a whole– Read the requirements of the change request– Focus on specifically what is supposed to

have changed.– Write a test while waiting for the change.– Run the test once you get the change from

the developer

Page 56: Automated testing 101

Tester Workflow

56

• Selenium IDE, Firefox Plugin– http://www.seleniumhq.org/download/

• Browser Specific– Chrome

https://sites.google.com/a/chromium.org/chromedriver/

– Safari http://selenium-release.storage.googleapis.com/2.46/SafariDriver.safariextz

Page 57: Automated testing 101

Tester Workflow

57

• Selenium– Installationhttp

://geekpad.ca/blog/post/automating-browser-testing-with-phpunit-and-selenium• First you must download the Selenium server and

the Internet Explorer Server from http://docs.seleniumhq.org/download/

• Then you must download the Chrome server from http://chromedriver.storage.googleapis.com/index.html

Page 58: Automated testing 101

Tester Workflow

58

• Selenium– Installation (continued)

• You do not need to download a Firefox driver since it’s builtin the main Selenium file.

• Once all files have been downloaded you must add your selenium folder to your existing path see http://www.java.com/en/download/help/path.xml

• Then you can launch the server using java. With something that looks like this– Mac - java -jar selenium-server-standalone-[version].jar

Page 59: Automated testing 101

Tester Workflow

59

Why is Selenium cool?

•Records your actions

•Let’s you test expected outcomes

•Let’s you test them in a series

Page 60: Automated testing 101

Tester Workflow

60

Example

•The developer was given a task to make sure that all instances of the word “Orange County” is replaced with the word “OC” on the website, for “legal reasons”.

•Demo

Page 61: Automated testing 101

Jenkins

61

Page 62: Automated testing 101

Jenkins

62

• Jenkins is an award-winning application that monitors executions of repeated jobs, such as building a software project or jobs run by cron. Among those things, current Jenkins focuses on the following two jobs:– Building/testing software projects continuously– Monitoring executions of externally-run jobs

https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins

Page 63: Automated testing 101

Jenkins

63

Page 64: Automated testing 101

Jenkins

64

Page 65: Automated testing 101

Questions?

65

Page 66: Automated testing 101

Resources

• http://www.dcs.bbk.ac.uk/~sven/cdm06/cdm3.pdf

• https://unit-tests.trac.wordpress.org/

• http://www.slideshare.net/ptahdunbar/automated-testing-in-wordpress-really

• http://johnregan3.co/2013/08/13/why-you-need-to-get-into-wordpress-unit-testing/

• http://blog.aizatto.com/2010/05/15/beginning-wordpress-automated-testing/

66

Page 67: Automated testing 101

Resources

• https://www.owasp.org/index.php/Testing_Guide_Introduction

• https://make.wordpress.org/core/handbook/automated-testing/

• http://stackoverflow.com/questions/22414134/different-types-of-testing-eg-unit-functional-integration-etc-document

67

Page 68: Automated testing 101

Resources

• http://www.seleniumhq.org/• http://geekpad.ca/blog/post/automating-browser-

testing-with-phpunit-and-selenium

• https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins

• https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins

68