Skip to content

dduleba/tw2019-workshop

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title

TW2019 BDD workshop

css

css/my.css

Testowanie BDD web aplikacji przy użyciu python'a oraz docker'a

Dariusz Duleba & Bartosz Bielicki, TestWarez 2019


image


Poznajmy się :)

Note

* my zaczynamy - następny slajd * przedstawienie się uczestników warsztatu? * jakie są oczekiwania uczestników? * jaki jest ich poziom wiedzy?


O nas

image

image

Dariusz Duleba Bartosz Bielicki
Software Engineer at Nokia DevOps Engineer at Huuuge Games

Wprowadzenie

O czym i co tak na prawdę będziemy robić?

Note

* 2 bloki * jedna przerwa w każdym bloku? (10 min) - ustalimy jeśli będzie potrzebna * niejasności i problemy wyjaśniamy na bieżąco


Konfigurowanie środowiska

  • instalacja VirtualBox'a 5.x/6.x
  • tworzenie maszyny wirtulanej na podstawie przygotowanego obrazu - 15 GB (hasło: tw2019)
  • rozwiązywanie problemów

Zapoznanie się ze środowiskiem

  • środowisko działa offline
  • wszytskie materiały dostępne są na GitHub
  • źródła_prezentacji
  • Ubuntu Mate 18.04.3
  • python 3
  • PyCharm

Zapoznanie się z aplikacją


Zapoznanie się z aplikacją

image


Piramida testów

image

https://i2.wp.com/ucgosu.pl/wp-content/uploads/2018/09/test_pyramid.png?ssl=1

Note

* Przerwa jeśli będzie potrzebna i czas pozwoli - 10 min


Testy integracyjne

Czego się nauczymy:

  1. jak utworzyć wirtualne środowisko python'a
  2. jak zaimplementować własnego REST klienta
  3. jak wykorzystać klienta i napisać własne testy integracyjne (backend + db)
  4. jak wygenerować raport z testów
  5. jak debugować testy z użyciem PyCharm

Note

* Jest to dobre wprowadzenie do środowiska przed przejściem do bardziej skomplikowanej implementacji testów, które wykorzystują BDD (gherkin) oraz selenium.


Python venv

$ python3 -m venv .env
$ . .env/bin/activate
$ pip install -U pip wheel
$ pip install -r requirements.txt
...
$ deactivate

Conduit REST klient

https://github.com/bbielicki/tw2019-app-client/blob/master/conduit/client.py


Testy integracyjne - scenariusze

  • rejestracja użytkownika
  • powtórna rejestracja użytkownika
  • pobranie informacji o zalogowanym użytkowniku
  • artykuł dostępny dla niezalogowanego użytkownika
  • polubienie artykułu - ćwiczenie

Raport z testów

$ nosetests --with-xunit test.backend

Debugowanie testów


Q&A

Note

* przerwa obiadowa


Testy UI

Czego się nauczymy:

  1. trzochę teorii: BDD, Gherkin, radish, selenium, page object pattern, ...
  2. jak napisać własne testy używając radish framework
  3. poznamy kolejne funkcjonalności nokia_radish_bdd_extensions
  4. jak odpalać testy selenium wykorzystując selenium docker image
  5. jak wygenerować raport z testów zaimplementowanych przy użyciu radish framework

Note

* testy będą podobne do testów integracyjnych ale będą to testy E2E/UI wykorzystujące przeglądarkę


Behaviour-Driven Development

Behaviour-Driven Development (BDD)

is the software development process that Cucumber was built to support.

What is BDD?

BDD is a way for software teams to work that closes the gap between business people and technical people by:

  • Encouraging collaboration across roles to build shared understanding of the the problem to be solved
  • Working in rapid, small iterations to increase feedback and the flow of value
  • Producing system documentation that is automatically checked against the system’s behaviour

We do this by focussing collaborative work around concrete, real-world examples that illustrate how we want the system to behave. We use those examples to guide us from concept through to implementation, in a process of continuous collaboration.


Gherkin

Gherkin is a Business Readable, Domain Specific Language created especially for behavior descriptions. It gives you the ability to remove logic details from behavior tests.


radish

radish is a Behavior Driven Development tool completely written in python.

Gherkin compatible

radish is fully compatible with cucumber's Gherkin language.

Additional feature syntax

In addition to the fully supported Gherkin language radish supports some more functionality like: Scenario Preconditions, Scenario Loops, Variables and Expressions.

Pythonic

radish tries to provide the most awesome pythonic experiences when implementing your steps and hooks. Your test code should be as great as your project's code.


Front End testing

selenium

Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) be automated as well.

Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.


selenium docker* polubienie artykułu


$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-vanadium
$ docker run --network host --name selenium --restart unless-stopped -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest

----E2E

testcontainers-python

python-testcontainers provides capabilities to spin up a docker containers for test purposes would that be a database, Selenium web browser or any other cotainer.


Other selenium docker compilations

  • selenoid
  • zalenium

  • logs attaching
    • in case of error handling
      • attach page source
      • attach page screenshot
      • attach page console logs
    • additional logging

Page object pattern

Page Objects are a testing pattern for websites. Page Objects model a page on your site to provide accessors and methods for interacting with this page, both to reduce boilerplate and provide a single place for element locators.


Testy UI - scenariusze

  • rejestracja użytkownika
  • rejestracja użytkownika ze znakami specjalnymi
  • logowanie użytkownika
  • błędne logowanie użytkownika
  • tworzenie artykułu
  • artykuł dostępny dla niezalogowanego użytkownika - ćwiczenie

Q&A

About

TestWarez2019 Workshop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 74.6%
  • Python 25.4%