@esconfs|#esconfs programming for testers it is easy! eurostar webinar tuesday 15 th september 2015...

20
@esconfs| #esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

Upload: dana-grant

Post on 29-Dec-2015

218 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Programming for TestersIt is easy!

EuroSTAR WebinarTuesday 15 th

September 2015

Presented by:Graham Thomas Phillip Isles

Page 2: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Abstract We hear a lot these days about how testers should learn to code, become more technical, and have more

development orientated skills. Unless you came into software testing as a ‘burnt out’ developer, it is unlikely that you have coding skills, or a deep understanding of the technical ins and outs of your current systems landscape.

What can you do about it? Is programming hard? How can you learn to code, gain the benefits and still master your current workload, which keeps on relentlessly increasing?

In this webinar, a companion piece to last year’s conference workshop, we show you how easy it actually is, as a tester, to learn how to program. The hard part, as always, is how to start. We will start with 3 simple steps and show you how to get up and running with Python.

And to help you back in the office we will arm you with some of the most useful on-line references and information that is available.

Each journey starts with a single step. Let us help you take your first programming step today.

Key Takeaways:◦ A deeper insight into the Testers need to learn to code debate◦ Your first steps into programming◦ Experience, examples and references to help you continue your Programming Adventure

Page 3: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Agenda Our Journey

The Why?

What learning to programme can give you

The How?

It’s easy – but not really!

The next steps on your own programming journey? Nasa

Hubble

New Horizons 2015

Pluto

Page 4: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Our JourneyBegan 2 years ago at Testers Retreat in September 2013, in the Netherlands.

◦ Asked if we would submit for a conference◦ Said yes, but would really like to run a workshop showing testers how to program◦ Using only free tools, show testers the basics, enthuse & inspire to want to learn more

Our submission was accepted for BTD and we had 3 months to prepare.◦ Decided to use; Python, Raspberry Pi, and a USB Robotic Arm!

Ran a rehearsal workshop with some of Phill’s colleagues

Then ran the workshop at 6 conferences, including EuroSTAR 2014◦ So there is Tester interest and demand for programming experience

Amazingly at every workshop a ‘non-programming’ tester successfully completed the final exercise, a challenge to program a USB Robotic Arm!

Page 5: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

3 months to design a workshop

We decided to base the workshop around Linux and Python.

We wanted to show how easy it was to get started, so we chose the Raspberry Pi, a credit card sized and fully functioning Linux computer, which costs only $35.

We decided to use Python as the programming language:◦ Python is free◦ Easy to use. Design philosophy emphasises readability◦ Syntax requires fewer lines of code than other languages, e.g. C◦ Powerful, scalable, and portable

And to make it fun, because that is how we learn best, we decided to build some exercises around programming a USB Robotic Arm (£29.95)

Raspberry Pi 2(Quad Core)

‘IoT’ ready

Python

USBRoboticArm

Page 6: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Ok, I am a Tester, why should I learn to code?

Well, you don’t have to learn to code.◦ You can work successfully as a tester without finding out the first thing about programming.

However, the world continues to change and move forward.◦ With the advent of agile approaches which encourage an understanding of code◦ And more recently the IoT ‘revolution’, and rapid prototyping approaches Makers

There are more and more opportunities for Testers who can understand code.

We do not think that as a tester you will have to sit there all day writing code, however being able to read code gives you several advantages:

◦ An understanding of how to write code will give you some insights into the kinds of errors that programmers make

◦ And you will get a feel for where errors are likely, given an understanding of how the code has been constructed

This will make you a better tester.◦ (There is also an argument that programmers should learn to test, and that will make them

better programmers, but that is not for today!)

RP

Page 7: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

So what do I get if I can code?

A bit better as a tester

But so much more:◦ When you sit there thinking, ‘If only I could . . . . ‘, well now you

can.◦ No longer do you have to wait for some programmer to come

free to reluctantly code some ‘demeaning test utility’◦ Write some code:

◦ Control scripts◦ Data Generation◦ Data Fuzzing◦ Results checking◦ Automate a manual process◦ Any utility you can think of . . . ◦ The possibilities are endless

All you need is a lightbulb

Graham: As a former programmer, I was amazed that testers couldn’t just code their own utilities. I could, did, and still do.

Page 8: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

A few disclaimers This is a webinar, it isn’t a highly interactive workshop, and there isn’t a 2-way discussion.

Phill and I are not teachers. In the workshops we just ‘show’ the delegates how to do things.

For those who are inspired to ‘have a go’, all of the code examples, a video, and a 30 page paper are freely available for download on my (Graham) website www.badgerscroft.com

The paper will also be shared after this webinar as a EuroSTAR e-book.

So if you get lost following us you know where to go and look.

Page 9: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Set-up “Nothing great was ever achieved without a few software installs!” – Anon.

Python◦ First, for windows users, we installed Python.

This comes as standard for Linux and Mac users.

Geany◦ We then installed the Geany IDE, Integrated Development

Environment.◦ You could write Python code in flat text files but using an

IDE brings with it some advantages such as:◦ Syntax Checking◦ Build tools◦ debugger ◦ Highlighting, context actions, autocomplete, configurable◦ Fast, free and lightweight

We used python 2 in the workshop, but python 3 is now the preferred option. The only difference is the print statement syntax. print (“hello world”)

Page 10: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Exercise 1 - Sequence We write a program to input 2 numbers and multiply them together.

As it is your first program there is a lot to do

We look at:◦ shebang - #! – which sets the environment◦ comments #◦ print◦ input◦ Variables

◦ str – string

◦ the compiler◦ and executing the program

Page 11: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Output The output doesn’t look particularly amazing.

Unless, that is, you have actually coded it.

There is a lot to cover in your first program, and this small program covers a lot of ground.

But just to get this far is an achievement.

You have gone beyond the simpleprint (“hello world”)

stage and begun to start writing code which will build into more complex programs.

Input Process Output

Page 12: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

12 @esconfs|#esconfs

Exercise 2 - Iteration We write a program that counts down to zero from an inputted number.

Here we see:◦ A more robust form of input – raw_input◦ Convert strings to integers◦ Look at Python indentation◦ How to construct a while loop

A loops is a very powerful construct. However get it wrong and the program can continue running forever, or more commonly until it crashes.

Page 13: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

13 @esconfs|#esconfs

Output This is still a very simple program, but is also very powerful.

We have formatted the output to leave a few blank lines to ease readability.

(If your program runs forever, try Ctrl-C, and work out where the error is.)

NB. We were asked to write a program that counted down to zero. There is a bug. A deliberate one we admit. We used a “>” comparator, but should have used “>=“.The sort of error testers are looking for!

In the workshop we also asked delegates to amend their program to count up to a number. That requires using the python comparator “==“

Repeat

Page 14: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

14 @esconfs|#esconfs

Exercise 3 - Decision Already our programs are becoming longer and more complex.

Ex. 3 compares 2 inputted numbers and reports which is the higher.

Here we are using the if, elif and else construct.(‘elif’ is python speak for ‘else if’)

And we are also formatting the output to look better on the screen.

Page 15: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

15 @esconfs|#esconfs

Output See how the output is more readable.

Think how many test cases you would need to test the logic in this simple comparison program.

When you have ‘tested’ it and are happy it works, try amending it to check whether the numbers are equal first, using the comparator “==“.

Armed with an understanding of sequence, iteration and decisions, you will be able to write quite complex programs even with a minimal understanding of python.

Q? Action A

Action B

Y

N

Page 16: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

16 @esconfs|#esconfs

Robot Arm - Challenge Flowchart + Code Template

Challenge:

Write a program to move the Robot Arm over a cup, drop an eraser held in its jaws, and report whether the eraser landed in the cup or not.

Page 17: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

17 @esconfs|#esconfs

Before you get carried away There is so much more:

◦ 80%+ of all code written is to handle errors and exceptions◦ The examples here are not bullet proof, as we easily

demonstrate in the workshop

Python is a very powerful language and we have only scratched the surface:

◦ A huge amount of built-in libraries◦ A feature rich and powerful language that we haven’t

begun to scratch with these exercises

We wanted to take you beyond print “Hello World”, get you started, and encourage, or inspire you to want to do more.

0%

10%

20%

30%

40%

50%

60%

70%

80%

90%

100%

80

20

Code

Happy PathExceptions

Page 18: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

References Python

◦ https://www.python.org/

Python Beginners Guide◦ https://

wiki.python.org/moin/BeginnersGuide/Programmers

On-line Python Tutorials◦ http://www.codecademy.com

Geany◦ http://www.geany.org/

Raspberry Pi Foundation◦ https://www.raspberrypi.org/

Visit my (Graham) website for full links, paper, slides, exercises, video, T-Shirt, etc.

◦ www.badgerscroft.com

And if you get stuck, try a google, bing, or Wikipedia search. Even look on YouTube for online tutorials.

A word of warning though!◦ Not everything that people post online is helpful,

and some of it is harmful, so if you are unsure, check a couple of references first

Page 19: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Summary We hope that we have inspired you to take your own python programming adventure.

Let today already be your first step.

For your next steps:◦ Download the paper◦ Work through the exercises◦ Go on-line and work through tutorials◦ Find a project to start programming

◦ Be that on the Raspberry Pi, or even at work

Start now by building a personal development plan . . . .

Nasa

Page 20: @esconfs|#esconfs Programming for Testers It is easy! EuroSTAR Webinar Tuesday 15 th September 2015 Presented by: Graham Thomas Phillip Isles 1

@esconfs|#esconfs

Thank you for listening

Graham ThomasIndependent Consultant

[email protected]@GrahamNThomas

Phill Isles

[email protected]