Selenium – Se – Unit Tests vs Functional Tests



Selenium – Se – Unit Tests vs Functional Tests

0 0


selenium_demo


On Github jonathangarza / selenium_demo

Selenium

Se

Created by Jonathan Garza

What is Selenium?

Selenium is a chemical element with symbol Se and atomic number 34. It is a nonmetal with properties that are intermediate between those of its periodic table column-adjacent chalcogen elements sulfur and tellurium. It rarely occurs in its elemental state in nature, or as pure ore compounds. Selenium (Greek σελήνη selene meaning "Moon") was discovered in 1817 by Jöns Jacob Berzelius, who noted the similarity of the new element to the previously known tellurium (named for the Earth).

Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).

Selenium - PyTest

Browser Automation and testing in Python

Created by Jonathan Garza

What is SeleniumHQ?

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!) also 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.

Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).

Let's see Selenium in action

Demo python order_tacos.py

Unit Tests vs Functional Tests

Let’s review. There are basically 2 kinds of automated tests: Unit and Functional.

Unit Tests

Unit tests are written from the developer’s perspective, and typically target a method or a class (did my sort method sort properly?).

Functional Tests

Functional tests (sometimes referred to as Integration tests by who prefer the extra syllable) are written from the user’s perspective, and usually test the interaction between multiple building blocks of the application (is the user able to log in? Can she update her account?).

"Unit testing makes sure you are using quality ingredients. Functional testing makes sure your application doesn't taste like crap." - Brett Jones

Let's see Selenium with PyPE

Several Test Made the html title fail. Demo py.test -s -v functional_tests/functional_tests.py

Testing considerations with UTDirect

"Please ensure that when you write your load testing scripts that you cache the authentication session information of your user(s). The goal of your load testing should be to test your application, not UTLogin." -Dustin Slater

  • Mock with PyPE app can fake UTDirect login process
  • PyTest fixtures

PyTest

Helps you write better programs

  • No boilerplate code
  • test discovery
  • Don't have to remember assert function names

PyTest

Do this...

def test_true():
  assert 1, True

Instead of...

import unittest

class TestMyStuff(unittest.TestCase):

  def test_the_obvious(self):
    self.assertEqual(True, True)

if __name__ == '__main__':
    unittest.main()

More to come...

THE END

BY Jonathan Garza