Thứ Sáu, 30 tháng 3, 2018

Auto news on Youtube Mar 30 2018

So I'm going to move on to some on-screen actions. So at this point we

have our environment setup and teardown taken care of, we have our basic

navigation of opening and closing notepad and getting the data that we

need to test the application. So now that we've done that you can see I have two

more utilities created here: one is input test data, one is a utility to interact

with the save dialog that appears, and one is to complete saving the data to a

file. So again, we've abstracted the actual logic of these so the

individual tests don't have to use this it's really just building the data

putting together the building blocks to create the test based off the utilities

that are created in the framework, and, as you can see, our get test data is being

passed around through the different utilities and it will basically what's

gonna happen here is when we get the data we assign certain things of the

data that are our input steps and so the utility here actually just sleeps

through all of our input data and then does a verification if you want it to.

And so this is what I'm saying if you need to add another column or more data

to your input you don't ever have to go update a single test you just need to

add a new line to your class for your test data object kind of same with the

save dialog we are abstracting the logic into the the framework so the main

options are save, don't save, cancel, none, and so this allows you know say the

dialog changes say it's you know not a dialog it's a new screen on the

application or something like that you can go and update these to just change

it in one spot and then all your tests that need to verify that something is

saved they still work again without having to worry about the logic. The

framework handles the logic and let's see we don't have any

verifications yet but we do have a few more things added to our contest

starting on test stop because we are now starting to get to the point where we

can actually save stuff and we're going to move on to verifications. This is

another part of environment setup and teardown and make sure the path that

we're going to save our results to is clean and empty so we don't run into any

overwrite errors or anything like that. I've also added a few extra utilities in

here it'll indent and outdent the log and add log folders for you,

logging our return data from our test data and added a few more things to our

setup environment and these are all still being used around everything else.

So at this point we can actually open up our smoke tests and you'll be able to

see that I have a few smoke tests created. So we have the verify open and

close, verify inputs text correctly, and verify that you can save. And if you

noticed none of these have any individual according we're just calling

the utilities and passing the data around

For more infomation >> Using On-Screen Actions: How to Build a Successful UI Automation Framework | TestComplete - Duration: 3:38.

-------------------------------------------

Minecraft: How to build a NPC Village hut - Duration: 4:48.

For more infomation >> Minecraft: How to build a NPC Village hut - Duration: 4:48.

-------------------------------------------

Setting Up Your Data & Prepping Your Environment: How to Build a Successful UI Automation Framework - Duration: 8:50.

So we're getting started if you look here in the source control repository I

have - I'm using - git which there is also I will post here in a little bit a link to a

github so you guys can pull down all of this info and see the kind of process

that I went through step by step. But the main thing we did here at first is

setting up just basic our basic structure we have our scripts which is

going to house all of our framework scripts so we have actions, data,

event handlers, different utilities, and verification scripts. We have templates

that we create a project template and that adds all of our scripts and our

name mapping files as existing items so you can then go in and clone the

template and it copies all these references so this allows you to update

only one script unit and have it propagate to all of your tests and then

some basic utilities nothing in here yet so the first step that I was talking

about is to get familiar with the application. So for my example I'm using

today I'm using notepad and then later I'll be using notepad plus plus to show

you how easy it is to switch between different versions and environments of

the application. So for today let's just assume the only requirement we have is

that you can pull test data, type it in, verify that what is on screen matches

what you typed in, that you can open and close the application, or you can save

what you typed in. And so we're gonna walk through process to create these

utilities that we need to make this happen. As you can see the first part

just kind of getting familiar with the application, I went through and just did

a straight record of all of the different elements that we're gonna be

interacting with just so I can kind of get an idea of what we're gonna be

working with here. So you know we can see how our menus are set up we can see that

we actually have a window edit the process name for notepad so on and so

forth. So let me go ahead and check out the branch where we have a little bit more

stuff going on a little more meat in our project here. So you can see here now we

have a smoke test project like I was saying that'll probably be one of the

first sets of tests that you want to create. We have a few more things in our

utilities now and we still have the same scripts that we had earlier. So in this

part you can see that we still don't have anything in action so we're not

even to on-screen actions yet but we do have some eventhandler stubbed out, we

have nothing else in the script genius yet. So we do have a name mapping

and what I've gone through is mapped the different elements of the test you can

see they're still hard-coded to very specific areas. The problem with this is if

we ever decided to run in a new environment or a you know different

version of the application and they put some different elements in between our

main window and our edit fields this test it's going to fail because it's

hard-coded to expect a certain way. So moving on to the next part we'll get

into the really fun stuff and that's setting up your data and prepping for

your environment so for the sake of time I'm going to skip through the first

couple parts of it and just get it to where we have some stuff working.

So you can see here now the name mapping that we had before we actually have

project variables set for the identification properties of some of

these. And this comes into play because the next part is setting up our

environment so you'll see I've used event handlers here. TestComplete's built

in a vest event handlers for starting the test and stopping the test and these

will fire off from a minute you could play until the test is from how many you

play it'll call the start start notepad test and when it stops it'll called the

stop notepad test. There's nothing in here right now what you do see we have

something in our utilities and it's called set up environment and so

basically what we have is a script here that will pull our environment data

based on two different versions of the application dev and test so I have pass

to our config files and we actually I'm using a Windows environment variables so

you can set this remotely you can set it to dev or test and then when you do that

it will open up or it will assign project variables to things like our

main app path the process we're expecting main window so on and so forth.

You don't have to use a config file the way I did you can pull it from database.

There's several different ways you can go about it but the main

important thing is to make sure that your tests can switch between

environments easily inside actions we have our open Notepad and close notepad

and what I did here is actually made both of these have an optional parameter

it's called verify so what this does is you'll see when we add test items later

the first one we're going to run first no custom verify the app can be open and

closed if it fails at any point in that then we'll stop the project log and say

hey there's no point running the rest of these tests because we can't even open

the application now. The thing is once you've ran that test you verify opens

you're not necessarily going to want to have to run those checkpoints every

single time it adds more time to the test it's really unneeded so that's why this

can be set to false and then it will just open the application and not try to

verify its existence. Down here you can see I've already started stubbing out

some actions for our main menu and so the like I said earlier our requirements

for this test for this application is just that you can open the application,

you can exit the application, and you can save. And the reason I set it up

with a JavaScript class for the properties for like the menu options and

everything like that it's so that your test can just call the, "hey, I want to do

the navigation option to save my document" well if that ever changes or

moves to a different menu or there's another dialog that pops up in there as

you're going through that process all you've got to do is update this one area.

Your logging stays consistent, you can now have your new path set up to

navigate to that part of the application and all of your tests are working again

without ever having to go touch an individual test.

Like I said, routine building blocks for tests here not the project for the tests

themselves so you can see we haven't added anything else to any of our other

tests yet except our data so we're gonna be inputting data and again here you

want to make sure your tests aren't responsible for the logic of getting

data all they need to be able to do is call a utility that returns the data

that you're expecting. I used classes here again and I'm setting I've set it

up to connect to an excel sheet as a database that's why you have the

different select statements here when the main reason I do it as an object or

a class in here as opposed to just referencing the data itself is you know

what happens if they decide they need to change a column name or what happens if

they say hey we need another column in our data in our environment

well the nice thing is if that happens all you have to do is just go modify

this one spot and it'll look through all the columns that you're inputting

without having to model by the tests themselves. I'll show a

little bit more about that here in a minute so that's kind of a basic set up

for our data and environment setup

For more infomation >> Setting Up Your Data & Prepping Your Environment: How to Build a Successful UI Automation Framework - Duration: 8:50.

-------------------------------------------

Getting Started in TestComplete: How to Build a Successful UI Automation Framework - Duration: 4:54.

that's kind of what I'm gonna be talking about here today is how to set up a

really good reliable and useful and easily maintainable automation framework

for UI functional tests. So we're gonna what we're gonna talk about here

is the process that goes through it. Automation frameworks kind of follow

the same thing that we're just talking about earlier with define decompose and

decide, so you kind of do the same thing with an automation framework. You

want to keep your actual logic for how the application

flows separated from your individual tests. The main reason for doing this

is it allows you to easily update in one spot if application changes whether it

be how its laid out on screen actual flow for doing common test routines

basically anything so you can update in one spot and however many thousands of

tests you're running are not broken when you get a newer version of your

application. So I'm gonna walk through the agenda here in

the PowerPoint and then I will get into kind of more of a live demo and

presentation for how to actually go about this so first of all you should

always be using source control you want to get your project structure your test

asset structure all of that set up the get-go it'll make your life a lot easier

in the long run if you have a really good organized test asset. You want...

first thing you would want to do is familiarize yourself with

the application do some exploratory testing start working on some basic name

mapping or object identification if you're doing it that way and just kind

of take notes on what your common flows are and what you're going to need to

create as far as utilities for your tests to use. One of the biggest steps

is you know we live in a world where there's all kinds of data being passed

around we're running on different environments especially if you have some

kind of continuous integration set up so the first thing you want to do from the

get-go is make sure that your application can be set up tore down data

can be grabbed from your test databases web

services or however you want to do it and start sitting up a smoke test

project because that's going to be your most ran tests every time you get any

release you're gonna want to be running smoke test before you even kick off the

full regression of your new release. You want to keep kind of your data that

you're getting from the wherever you're pulling it from whether it be an excel

file a test database a love service and kind of abstract that data out into your

own objects with inside of your framework. This allows you to not have to

rely on the layout of the data being static doesn't allow so you didn't have

to rely on it being in the same place all the time and so your tests you focus

more on testing the functionality of the application not the logic behind how to

get the application running in the data you need. On-screen actions we're gonna

do basically the same kind of thing we do with the data we're gonna make sure

that the framework handles all of the actions that you're creating and so when

you get ready to start creating test you don't have to worry about that logic all

you're doing is putting in place different building blocks. I kind

of like to equate a UI automation framework is kind of like a mini

application where you're developing tools for other automation developers to

create the tests any actions that are going to be interacting with your data

you want to be able to use those same data objects that you're creating in

your data scripts so all you have to do is just pass one object around all of

your tests and you always know the data that you're gonna have is going to be

there you can verify your expected results and make sure your application

is meeting its requirements. You're gonna hear me say this a lot make sure

everything kind of interrupts together your verifications you know if you're

grabbing data and putting them into a text field and you want to verify that

the data is written correctly well you don't want to hard-code any of that you

want to use the data that you got and verify the application behaves specific

there behaves to meet the requirements. Again we're still everything kind of

works together we're making building blocks here and I'll show you what is

really useful and why this is a really good idea to do when I get into the live

presentation and then finally if you've set everything up properly it should be

very easy to ajust how you're logging exporting your

your test run logs to a specific network share or web server reporting being able

to send out emails to alert people that you know build failed hey we have

problems we need someone looking at this so that's kind of the the really high

level overview what I'm going to be talking about

For more infomation >> Getting Started in TestComplete: How to Build a Successful UI Automation Framework - Duration: 4:54.

-------------------------------------------

Creating Your Tests: How to Build a Successful UI Automation Framework | TestComplete - Duration: 6:46.

Let me go ahead and switch over to a printer that has our verifications

included and I'll show you just how easy it is to start writing tesst once you

have a good framework set up. Okay, so you can see here we have a few more

verifications; we have a new method to our data object that's calls verify

saved data and what that will actually do is take the expected data that is

built from our test data. When we save a file, it'll set properties on this object

to the path that it's safe to and then it will actually verify that the full

contents of the file matched what you typed in so for part of that we also

added in some verify that the files are saved inside of our save dialogue and

saved file scripts it sets properties of the data object that we have and then it

returns it again so I'll show you here just kind of how

easy it is to write a test you need to write a new test all you have to do is

drag over some options so open notepad we will get test data we're gonna get

test data that is a type of company

and if you remember that returns the test data object we're gonna do another

actions and we're gonna say input test data and for the data object we are

going to say that is the last result which was the test "get test data" and

we're also going to say true on this clear option. So basically what that's

going to do is it will clear out anything that is currently in notepad in

case there is and then we're also going to say verify and it will say true to

that and basically what that's going to do is everything we type in there it's

going to verify that it shows up on screen correctly and then for our last

action for this test we will do menu navigation and what was the option I

gave for that how did it go so many navigation and it's just exit that makes

sense. So that brings me actually to a another point that I want to make if you

know. I missed it even for me who wrote this sometimes it gets a little tricky

remembering where certain things live, what they do, what you need to call to do

certain actions on your application, so I highly recommend either building your

own or using some kind of free open-source tool to generate

documentation. I actually use one that's called es doc all you have to do is if

you have node.js installed it's an NPM package and what it does is it'll parse

your block comments and give you a nice clean web page for documenting all of

your framework utilities. So like I saw here the or I mentioned earlier the menu

navigation so it will say hey whether the option is and it's from the nav

options object so you can see here that we have X

and save. So within very little time at all I've created a test here that will

actually open up notepad get test data from our test database and put the data

in and exit the test so if you see here I actually still have that pop-up up so

and that's because I forgot to let's see did I not put that in yet so actually I

shouldn't have done the fall nav option I should have done close notepad because

if you see here that has a default of bypassing the save dialog. So let's go

ahead and remove that guy and do close dialogue or close notepad and if we run

that again it should actually close for us.

there we go so let's do a fun little test here, hopefully that'll work for me

better and then it did this morning when it didn't work for me so let's say we

just got a new version of the application from dev and or the purpose

of this demonstration I'm gonna say that the new version is just notepad plus

plus and so we actually set our environments with Windows environment

variables like I said before and so just to kind of show an example here, here's

what notepad plus plus looks like here's what notepad looks like. Looks like we're

probably not gonna be able to run the same test we just created, right?

So let's try it and see how it works.

And there we go! Aame test completely different application changes were made

to it but because we've set everything right up from the get-go we're still

verifying functionality of that you can see it's still putting in the keyboard

it's still verifying that the everything matches what we want same test exactly

completely new version of application with changes we didn't even have to

update anything except our environment config

Không có nhận xét nào:

Đăng nhận xét