20
eleks.com eleks.com Integration testing And UI testing (Selenium Web driver)

#2 integration + ui tests

Embed Size (px)

Citation preview

Page 1: #2 integration + ui tests

eleks.com eleks.com

Integration testingAnd UI testing (Selenium Web driver)

Page 2: #2 integration + ui tests

Tests can be different

Page 3: #2 integration + ui tests

Integration tests featuresTest several components togetherUse dependencies (DB, Services, API, FS, AD, ...)Can have different behaviorRequire configurationResults can be different (depend on environment,

order of execution, multithreading, phase of Moon).

Page 4: #2 integration + ui tests

Integration tests featuresFollowing code can often be seen in

integration testsFile.Open(...)Connection.Close(...)Environment.MachineNameDateTime.NowTearDown(...)

Page 5: #2 integration + ui tests

Integration tests “Pro’s”

Pro’s:Make sure nuts and bolts fit togetherMake sure software stack components interact

smoothly Test behavior and infrastructure (tested code)/test

% is highReflect typical workflows

Page 6: #2 integration + ui tests

Integration tests “Con’s”

Con’s: Large time investmentHard to test all critical pathsHarder to localize source of errorsHarder to write and maintain

Page 7: #2 integration + ui tests

Project structure

Unit and integration tests should be separatedCommon practice is to end up project name with “.Tests” suffix

Page 8: #2 integration + ui tests

eleks.com eleks.com

Show me the code![integration test examples]

Page 9: #2 integration + ui tests

eleks.com eleks.com

UI testingTesting Web apps using Selenium

Page 10: #2 integration + ui tests

Wait, UI?Web Apps are Heterogeneous systems at mostDifferent technology stacks for backendComplex multi-layer and multi-tier systemsShould test all involved partsCan’t directly test server code and SQLEverything can go wrong...

Page 11: #2 integration + ui tests

Front end test featuresPros:Hide the complexity of a backendTests can reproduce exactly what users doCan detect errors not visible by other types of testsUI tests can be utilized for any automation in

general

Page 12: #2 integration + ui tests

Front end test featuresCons:Execution timeThird party tools/environmentsHard to maintainComplexityDynamic pages

Page 13: #2 integration + ui tests

What is it?

Selenium is a Functional Automation tool for Web apps Works with different languages, browsers, Oses etc. Interacts with Web app via UI

Page 14: #2 integration + ui tests

What is my options?Selenium 2 (Selenium Web Driver)Selenium 1 (Selenium RC)Selenium IDESelenium-Grid

More details at: http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp

Page 15: #2 integration + ui tests

Selenium Web DriverInteractions via DRIVERsVarious drivers are supported:Chrome driver, Opera driver, Android driver, IOS

driver

Page 16: #2 integration + ui tests

UI Test key partsStart driverIWebDriver driver = new FirefoxDriver();Navigate to desired pagedriver.Navigate().GoToUrl(“...”);Find controls for interactionvar elem =

driver.FindElement(By.Name(“...”));Actelem.SendKeys(“Ok, Google”);

Page 17: #2 integration + ui tests

UI Test key partsWait/* WebDriverWait is preferred, but

Thread.Sleep will also work*/Assertsomething.Should.Be(...);Exit/Clean updriver.Close();

Page 18: #2 integration + ui tests

Selenium APIEasy to find controls/tagsBy name, id, css, xpath etc. Easy to navigateSelect active windowSwitch to urlEasy integrates with NUnitNo need for installers, manual process running etc

Page 19: #2 integration + ui tests

eleks.com eleks.com

UI automated tests example[Asp.Net 5 + NUnit + Selenium WebDriver]

Page 20: #2 integration + ui tests

It’s time to practice