SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
Modern
Testing
Alexander Loechel
PloneConf 2017 - Barcelona
The Goal of Testing
→ Produce high quality / correct software
“Program testing can be used to show
the presence of bugs, but never show
their absence!”
Edsger Dijkstra
Testing is about
responsibility & sustainability
→ Path for Plone on Python 3
What to test
● Requirements
● Design
● Interfaces
● Code / Implementation
● Documentation
● Conventions
Test Design / Types
V-ModelUser Requirements Acceptance Test
Requirements Verification Functional Test
System Design Validation System Integration Test
Detailed Design Subsystem Integration Tests
Software Architecture (Interfaces) Unit-Tests
Coding / Implementation
Classical Software Development Process / Governmental Standard
Open Source Development
The development process in Open Source Projects work differently,
but a lot of the concepts of the V-Model are reflected in other ways.
Documentation
→ Reflects Requirements, Intentions and Design
Tests reflects the requirements
⇒ TTD - Test Driven Development
“Testing leads to failure,
and failure leads to understanding.”
Burt Rutan
Writing tests is mandatory for good software
Definitions
Test
A test is a specific set of assertions
Test Case
A test case is the smallest unit of testing.
It checks for a specific response to a particular set of inputs.
Test Fixture
A test fixture represents the preparation needed to perform
one or more tests, and any associate cleanup actions
Test Suite
A test suite is a collection of test cases, test suites, or both.
It is used to aggregate tests that should be executed together.
Test Layer
(plone.testing / plone.app.testing)
A test layer represents the baseline for a specific test
→ Reflects Test-Level in V-Model
● Unit tests
● Integration tests
● Functional tests
● Acceptance tests
Test Runner
A test runner is a component which orchestrates the execution of tests
and provides the outcome to the user.
Test Invocation Tool
A test invocation tool is a component which provides the
required infrastructure to the test runner to execute the test sets.
Mock
mock is a library for testing in Python.
It allows you to replace parts of your system under test with mock objects and
make assertions about how they have been used.
→ Test Isolation
Writing test / What to test
● Requirements → Acceptance tests
● Design → Functional tests
● Interfaces → Integration tests
● Code / Implementation → Unit tests
● Documentation → Test if your code examples actually works
● Conventions → Test if the convention of the project is followed
(e.g. Coding Conventions)
Test Frameworks
Unittest
The Python unit testing framework, sometimes referred to as “PyUnit,” is a Python language version of JUnit, by Kent Beck
and Erich Gamma. JUnit is, in turn, a Java version of Kent’s Smalltalk testing framework. Each is the de facto standard unit
testing framework for its respective language.
unittest supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections,
and independence of the tests from the reporting framework. The unittest module provides classes that make it easy to
support these qualities for a set of tests.
● Python Standard Library module
● Used in Plone for testing
● Specific BaseClasses, and assert methods necessary, setup and teardown
methods
Unitest example
(Plone context - Plone Training Documentation)
import unittest
class TalkIntegrationTest(unittest.TestCase):
layer = PLONECONF_SITE_INTEGRATION_TESTING
def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
def test_fti(self):
fti = queryUtility(IDexterityFTI, name='talk')
self.assertTrue(fti)
def test_adding(self):
self.portal.invokeFactory('talk', 'talk')
self.assertTrue(self.portal.talk)
self.assertTrue(ITalk.providedBy(self.portal.talk))
…
suite = unittest.TestLoader().loadTestsFromTestCase(TalkIntegrationTest)
Assert Methods
Method Checks that
assertEqual(a, b) a == b
assertNotEqual(a, b) a != b
assertTrue(x) bool(x) is True
assertFalse(x) bool(x) is False
assertIs(a, b) a is b
assertIsNot(a, b) a is not b
assertIsNone(x) x is None7
assertIsNotNone(x) x is not None
assertIn(a, b) a in b
assertNotIn(a, b) a not in b
assertIsInstance(a, b) isinstance(a, b)
assertNotIsInstance(a, b) not isinstance(a, b)
“The pytest framework makes it easy to write small tests, yet scales to support
complex functional testing for applications and libraries.”
● De Facto Standard in the Python world
● Some magic to make writing tests simpler
● just assert
● Implicit test loader
● Plugable addon system
pytest example
(Plone context - RestrictedPython)
from tests import e_eval
import pytest
@pytest.mark.parametrize(*e_eval)
def test_Eq(e_eval):
assert e_eval('1 == 1') is True
@pytest.mark.parametrize(*e_eval)
def test_NotEq(e_eval):
assert e_eval('1 != 2') is True
@pytest.mark.parametrize(*e_eval)
def test_Gt(e_eval):
assert e_eval('2 > 1') is True
@pytest.mark.parametrize(*e_eval)
def test_Lt(e_eval):
assert e_eval('1 < 2')
unittest2 / nose / nose2
Forks of unitest that either enhance or backport functionality
Mostly outdated and not recommended anymore.
Robot Framework
Robot Framework is a generic test automation framework for acceptance testing
and acceptance test-driven development (ATDD).
● Focus: Web Applications
● Wrapper around Selenium
Robot tests example
(Plone context - Plone Training Documentation)
*** Settings ***********************************************
Resource plone/app/robotframework/selenium.robot
Resource plone/app/robotframework/keywords.robot
Library Remote ${PLONE_URL}/RobotRemote
Test Setup Open test browser
Test Teardown Close all browsers
*** Test Cases *********************************************
Scenario: As a site administrator I can add a Talk
Given a logged-in site administrator
and an add talk form
When I type 'My Talk' into the title field
and I type 'Awesome talk' into the details field
and I type 'Team Banzai' into the speakers field
and I type 'banzai@example.com' into the email field
and I submit the form
Then a talk with the title 'My Talk' has been created
Scenario: As a site administrator I can view a Talk
Given a logged-in site administrator
and a talk 'My Talk'
When I go to the talk view
Then I can see the talk title 'My Talk'
Scenario: As a visitor I can view the new talk list
When I go to the talk list view
Then I can see a talk about 'Diazo designs are great'
*** Keywords ****************************************
# --- Given ------------------------------------------
a logged-in site administrator
Enable autologin as Site Administrator
an add talk form
Go To ${PLONE_URL}/++add++talk
a talk 'My Talk'
Create content type=talk id=my-talk title=My Talk
# --- WHEN --------------------------------------------
I type '${title}' into the title field
Input Text name=form.widgets.IDublinCore.title ${title}
I type '${details}' into the details field
Select frame form-widgets-details_ifr
Input text tinymce ${details}
Unselect Frame
I type '${speaker}' into the speakers field
Input Text name=form.widgets.speaker ${speaker}
I type '${email}' into the email field
Input Text name=form.widgets.email ${email}
I submit the form
Click Button Save
I go to the talk view
Go To ${PLONE_URL}/my-talk
Wait until page contains Site Map
I go to the talk list view
Go To ${PLONE_URL}/demoview
Wait until page contains Site Map
# --- THEN ----------------------
a talk with the title '${title}' has been created
Wait until page contains Site Map
Page should contain ${title}
Page should contain Item created
I can see the talk title '${title}'
Wait until page contains Site Map
Page should contain ${title}
I can see a talk about '${topic}'
Wait until page contains Site Map
Page should contain ${topic}
“The first principle is that you must not
fool yourself - and you are the easiest
person to fool.”
Richard Feynman
Test runners
● unittest testrunner
● zope.testrunner
● pytest-testrunner
● gocept.pytestlayer
A test runners is a component which orchestrates the execution of tests and
provides the outcome to the user.
● collects tests
● presents outcome
● interact with other tools (e.g. coverage)
Test invocation tools
● Command line
● Continuous Integration Servers
● tox
Test invocation tools
● Command line
○ python setup.py tests
○ python -m unittest test_module.TestClass
○ python -m pytest tests
○ bin/test (zc.buildout script generated by zope.recipe.testrunner)
● Continuous Integration Servers
(Linux/MacOS X - Machines)
perfect for pure Python tests
(Docker containers, Linux/MacOS X)
(Windows)
Test invocation tools
travis-ci example
(Plone context - RestrictedPython)
language: python
sudo: false
matrix:
include:
- python: "2.7"
env: TOXENV=docs,lint-py27
- python: "3.6"
env: TOXENV=docs,lint-py36
- python: "2.7"
env: TOXENV=py27
- python: "2.7"
env: TOXENV=py27-datetime
- python: "3.4"
env: TOXENV=py34
- python: "3.5"
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36
- python: "3.6"
env: TOXENV=py36-datetime
- python: "3.7-dev"
env: TOXENV=py37
- python: "pypy"
env: TOXENV=pypy
- python: "pypy3"
env: TOXENV=pypy
allow_failures:
- python: "3.7-dev"
env: TOXENV=py37
install:
- travis_retry pip install -U pip
setuptools
- travis_retry pip install -U -c
constraints.txt tox coveralls coverage
script:
- travis_retry tox
after_success:
- coverage combine
- coveralls
notifications:
email: false
Test invocation tools
● tox - Translate the concept of continuous Integration to local development
○ De facto standard as a local test invocation tool
○ Groups environments, allow to test different Python versions support
Fantastic if you use additional helpers:
● pyenv - having multiple Python version
● git-hooks - run scripts on git commands → pre-commit hook
tox example
(Plone context - RestrictedPython)
[tox]
envlist =
py{27,34,35,36},
docs,
lint-py27,
lint-py36,
coverage,
skip_missing_interpreters = False
[testenv]
usedevelop = True
extras =
develop
commands =
pytest --cov=src --cov-report=xml --html=reports/pytest/report-{envname}.html --doctest-glob=*.rst --self-contained-html
{posargs}
pytest --doctest-modules src/RestrictedPython/compile.py {posargs}
setenv =
COVERAGE_FILE=.coverage.{envname}
deps =
-cconstraints.txt
pytest-cov
pytest-remove-stale-bytecode
pytest-html
[testenv:coverage]
basepython = python2.7
skip_install = true
deps =
-cconstraints.txt
coverage
setenv =
COVERAGE_FILE=.coverage
commands =
coverage erase
coverage combine
coverage html
coverage xml
coverage report
[testenv:docs]
deps =
-cconstraints.txt
Sphinx
commands =
python -V
sphinx-build -b html -d build/docs/doctrees docs build/docs/html
sphinx-build -b doctest docs build/docs/doctrees
tox example - Linter - enforce Coding Conventions
(Plone context - RestrictedPython)
[lint]
skip_install = true
deps =
-cconstraints.txt
isort
flake8
# helper to generate HTML reports:
flake8-html
# Useful flake8 plugins that are Python and Plone specific:
flake8-coding flake8-debugger flake8-deprecated
Flake8-print flake8-pytest flake8-todo flake8-isort
mccabe
# Potential flake8 plugins that should be used:
Flake8-blind-except flake8-commas,flake8-docstrings
Flake8-pep3101 flake8-plone-hasattr, flake8-string-format
Flake8_strict flake8-quotes
commands =
mkdir -p {toxinidir}/reports/flake8
isort --check-only --recursive {toxinidir}/src {toxinidir}/tests setup.py
- flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src tests setup.py
flake8 src tests setup.py --doctests
whitelist_externals =
mkdir
[testenv:lint-py27]
basepython = python2.7
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}
[testenv:lint-py36]
basepython = python3.6
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}
The Zen of Python - PEP20
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
...
Lessons learned from Zope and Plone
→ we should embrace each tool that helps us to provide a fantastic products
My Wishes to better “Best Practices” for Plone
● Adopt tox on all packages
● Switch to a different package structure and enforce that → bobtemplates.plone
○ docs
○ src
○ tests
● detailed and enforced settings for conventions
○ .editorconf
○ setup.cfg
→ https://github.com/plone/plone_best_practices_discussion

Weitere ähnliche Inhalte

Was ist angesagt?

Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Edureka!
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and PackagesDamian T. Gordon
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking frameworkPhat VU
 
Python Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaPython Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaEdureka!
 
Packages In Python Tutorial
Packages In Python TutorialPackages In Python Tutorial
Packages In Python TutorialSimplilearn
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in PythonSujith Kumar
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Testes pythonicos com pytest
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytestviniciusban
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development CodeOps Technologies LLP
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next ChapterVictor Rentea
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With PythonSiddhi
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentguestc8093a6
 

Was ist angesagt? (20)

Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
Exception Handling In Python | Exceptions In Python | Python Programming Tuto...
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
 
Python Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaPython Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | Edureka
 
Junit
JunitJunit
Junit
 
Packages In Python Tutorial
Packages In Python TutorialPackages In Python Tutorial
Packages In Python Tutorial
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
testng
testngtestng
testng
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Testes pythonicos com pytest
Testes pythonicos com pytestTestes pythonicos com pytest
Testes pythonicos com pytest
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Python OOPs
Python OOPsPython OOPs
Python OOPs
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next Chapter
 
Test Driven Development With Python
Test Driven Development With PythonTest Driven Development With Python
Test Driven Development With Python
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
PyCharm demo
PyCharm demoPyCharm demo
PyCharm demo
 

Ähnlich wie Modern Testing Approaches and Frameworks

Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesTao Xie
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Plone testingdzug tagung2010
Plone testingdzug tagung2010Plone testingdzug tagung2010
Plone testingdzug tagung2010Timo Stollenwerk
 
May: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesMay: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesTriTAUG
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suiteericholscher
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnitTuan Nguyen
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontendHeiko Hardt
 
Mastering PowerShell Testing with Pester
Mastering PowerShell Testing with PesterMastering PowerShell Testing with Pester
Mastering PowerShell Testing with PesterMark Wragg
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Pantheon
 
Unit Testing in R with Testthat - HRUG
Unit Testing in R with Testthat - HRUGUnit Testing in R with Testthat - HRUG
Unit Testing in R with Testthat - HRUGegoodwintx
 
Comparative Development Methodologies
Comparative Development MethodologiesComparative Development Methodologies
Comparative Development Methodologieselliando dias
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIwajrcs
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Scott Keck-Warren
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationPaul Blundell
 

Ähnlich wie Modern Testing Approaches and Frameworks (20)

Automated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and ChallengesAutomated Developer Testing: Achievements and Challenges
Automated Developer Testing: Achievements and Challenges
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
 
10071756.ppt
10071756.ppt10071756.ppt
10071756.ppt
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Plone testingdzug tagung2010
Plone testingdzug tagung2010Plone testingdzug tagung2010
Plone testingdzug tagung2010
 
May: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and ChallengesMay: Automated Developer Testing: Achievements and Challenges
May: Automated Developer Testing: Achievements and Challenges
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnit
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Mastering PowerShell Testing with Pester
Mastering PowerShell Testing with PesterMastering PowerShell Testing with Pester
Mastering PowerShell Testing with Pester
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
Unit Testing in R with Testthat - HRUG
Unit Testing in R with Testthat - HRUGUnit Testing in R with Testthat - HRUG
Unit Testing in R with Testthat - HRUG
 
Comparative Development Methodologies
Comparative Development MethodologiesComparative Development Methodologies
Comparative Development Methodologies
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 

Mehr von Alexander Loechel

Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...Alexander Loechel
 
The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!Alexander Loechel
 
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.Alexander Loechel
 
Plone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon ListingPlone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon ListingAlexander Loechel
 
Sphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understandSphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understandAlexander Loechel
 
Web Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the FutureWeb Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the FutureAlexander Loechel
 
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-DevelopersPlone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-DevelopersAlexander Loechel
 
Plone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesPlone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesAlexander Loechel
 
Web Accessibility for Web Developers
Web Accessibility for Web DevelopersWeb Accessibility for Web Developers
Web Accessibility for Web DevelopersAlexander Loechel
 
World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1Alexander Loechel
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python WebAlexander Loechel
 
Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Alexander Loechel
 

Mehr von Alexander Loechel (14)

Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
Lightning Talk: Regulation (EU) 2018/1724 "Single Digital Gateway" & the "You...
 
The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!The Plone is dead, long live the Plone!
The Plone is dead, long live the Plone!
 
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
We are the Plone Collective. Resistance is futile. Assimilation is inevitable.
 
Plone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon ListingPlone.org Improvements - Plone Addon Listing
Plone.org Improvements - Plone Addon Listing
 
Plone, quo vadis?
Plone, quo vadis?Plone, quo vadis?
Plone, quo vadis?
 
Sphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understandSphinx options to make training documentation easier to understand
Sphinx options to make training documentation easier to understand
 
Web Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the FutureWeb Content-Management-Systeme the Past - the Present - the Future
Web Content-Management-Systeme the Past - the Present - the Future
 
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-DevelopersPlone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
Plone, the Python CMS & Web Framework for Advanced Topics and Non-Developers
 
Plone im Kontext des WCMS Marktes
Plone im Kontext des WCMS MarktesPlone im Kontext des WCMS Marktes
Plone im Kontext des WCMS Marktes
 
Web Accessibility for Web Developers
Web Accessibility for Web DevelopersWeb Accessibility for Web Developers
Web Accessibility for Web Developers
 
Doing the Impossible
Doing the ImpossibleDoing the Impossible
Doing the Impossible
 
World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1World Plone Day 2017 - Plone 5.1
World Plone Day 2017 - Plone 5.1
 
Plone - A History of Python Web
Plone - A History of Python WebPlone - A History of Python Web
Plone - A History of Python Web
 
Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014Lightning Talk: Security matters @ploneconf 2014
Lightning Talk: Security matters @ploneconf 2014
 

Kürzlich hochgeladen

Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxRTS corp
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 

Kürzlich hochgeladen (20)

Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Advantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptxAdvantages of Cargo Cloud Solutions.pptx
Advantages of Cargo Cloud Solutions.pptx
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 

Modern Testing Approaches and Frameworks

  • 2. The Goal of Testing → Produce high quality / correct software “Program testing can be used to show the presence of bugs, but never show their absence!” Edsger Dijkstra
  • 3. Testing is about responsibility & sustainability → Path for Plone on Python 3
  • 4. What to test ● Requirements ● Design ● Interfaces ● Code / Implementation ● Documentation ● Conventions
  • 5. Test Design / Types V-ModelUser Requirements Acceptance Test Requirements Verification Functional Test System Design Validation System Integration Test Detailed Design Subsystem Integration Tests Software Architecture (Interfaces) Unit-Tests Coding / Implementation Classical Software Development Process / Governmental Standard
  • 6. Open Source Development The development process in Open Source Projects work differently, but a lot of the concepts of the V-Model are reflected in other ways. Documentation → Reflects Requirements, Intentions and Design Tests reflects the requirements ⇒ TTD - Test Driven Development
  • 7. “Testing leads to failure, and failure leads to understanding.” Burt Rutan Writing tests is mandatory for good software
  • 9. Test A test is a specific set of assertions
  • 10. Test Case A test case is the smallest unit of testing. It checks for a specific response to a particular set of inputs.
  • 11. Test Fixture A test fixture represents the preparation needed to perform one or more tests, and any associate cleanup actions
  • 12. Test Suite A test suite is a collection of test cases, test suites, or both. It is used to aggregate tests that should be executed together.
  • 13. Test Layer (plone.testing / plone.app.testing) A test layer represents the baseline for a specific test → Reflects Test-Level in V-Model ● Unit tests ● Integration tests ● Functional tests ● Acceptance tests
  • 14. Test Runner A test runner is a component which orchestrates the execution of tests and provides the outcome to the user.
  • 15. Test Invocation Tool A test invocation tool is a component which provides the required infrastructure to the test runner to execute the test sets.
  • 16. Mock mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used. → Test Isolation
  • 17. Writing test / What to test ● Requirements → Acceptance tests ● Design → Functional tests ● Interfaces → Integration tests ● Code / Implementation → Unit tests ● Documentation → Test if your code examples actually works ● Conventions → Test if the convention of the project is followed (e.g. Coding Conventions)
  • 19. Unittest The Python unit testing framework, sometimes referred to as “PyUnit,” is a Python language version of JUnit, by Kent Beck and Erich Gamma. JUnit is, in turn, a Java version of Kent’s Smalltalk testing framework. Each is the de facto standard unit testing framework for its respective language. unittest supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework. The unittest module provides classes that make it easy to support these qualities for a set of tests. ● Python Standard Library module ● Used in Plone for testing ● Specific BaseClasses, and assert methods necessary, setup and teardown methods
  • 20. Unitest example (Plone context - Plone Training Documentation) import unittest class TalkIntegrationTest(unittest.TestCase): layer = PLONECONF_SITE_INTEGRATION_TESTING def setUp(self): self.portal = self.layer['portal'] setRoles(self.portal, TEST_USER_ID, ['Manager']) def test_fti(self): fti = queryUtility(IDexterityFTI, name='talk') self.assertTrue(fti) def test_adding(self): self.portal.invokeFactory('talk', 'talk') self.assertTrue(self.portal.talk) self.assertTrue(ITalk.providedBy(self.portal.talk)) … suite = unittest.TestLoader().loadTestsFromTestCase(TalkIntegrationTest) Assert Methods Method Checks that assertEqual(a, b) a == b assertNotEqual(a, b) a != b assertTrue(x) bool(x) is True assertFalse(x) bool(x) is False assertIs(a, b) a is b assertIsNot(a, b) a is not b assertIsNone(x) x is None7 assertIsNotNone(x) x is not None assertIn(a, b) a in b assertNotIn(a, b) a not in b assertIsInstance(a, b) isinstance(a, b) assertNotIsInstance(a, b) not isinstance(a, b)
  • 21. “The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.” ● De Facto Standard in the Python world ● Some magic to make writing tests simpler ● just assert ● Implicit test loader ● Plugable addon system
  • 22. pytest example (Plone context - RestrictedPython) from tests import e_eval import pytest @pytest.mark.parametrize(*e_eval) def test_Eq(e_eval): assert e_eval('1 == 1') is True @pytest.mark.parametrize(*e_eval) def test_NotEq(e_eval): assert e_eval('1 != 2') is True @pytest.mark.parametrize(*e_eval) def test_Gt(e_eval): assert e_eval('2 > 1') is True @pytest.mark.parametrize(*e_eval) def test_Lt(e_eval): assert e_eval('1 < 2')
  • 23. unittest2 / nose / nose2 Forks of unitest that either enhance or backport functionality Mostly outdated and not recommended anymore.
  • 24. Robot Framework Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). ● Focus: Web Applications ● Wrapper around Selenium
  • 25. Robot tests example (Plone context - Plone Training Documentation) *** Settings *********************************************** Resource plone/app/robotframework/selenium.robot Resource plone/app/robotframework/keywords.robot Library Remote ${PLONE_URL}/RobotRemote Test Setup Open test browser Test Teardown Close all browsers *** Test Cases ********************************************* Scenario: As a site administrator I can add a Talk Given a logged-in site administrator and an add talk form When I type 'My Talk' into the title field and I type 'Awesome talk' into the details field and I type 'Team Banzai' into the speakers field and I type 'banzai@example.com' into the email field and I submit the form Then a talk with the title 'My Talk' has been created Scenario: As a site administrator I can view a Talk Given a logged-in site administrator and a talk 'My Talk' When I go to the talk view Then I can see the talk title 'My Talk' Scenario: As a visitor I can view the new talk list When I go to the talk list view Then I can see a talk about 'Diazo designs are great' *** Keywords **************************************** # --- Given ------------------------------------------ a logged-in site administrator Enable autologin as Site Administrator an add talk form Go To ${PLONE_URL}/++add++talk a talk 'My Talk' Create content type=talk id=my-talk title=My Talk # --- WHEN -------------------------------------------- I type '${title}' into the title field Input Text name=form.widgets.IDublinCore.title ${title} I type '${details}' into the details field Select frame form-widgets-details_ifr Input text tinymce ${details} Unselect Frame I type '${speaker}' into the speakers field Input Text name=form.widgets.speaker ${speaker} I type '${email}' into the email field Input Text name=form.widgets.email ${email} I submit the form Click Button Save I go to the talk view Go To ${PLONE_URL}/my-talk Wait until page contains Site Map I go to the talk list view Go To ${PLONE_URL}/demoview Wait until page contains Site Map # --- THEN ---------------------- a talk with the title '${title}' has been created Wait until page contains Site Map Page should contain ${title} Page should contain Item created I can see the talk title '${title}' Wait until page contains Site Map Page should contain ${title} I can see a talk about '${topic}' Wait until page contains Site Map Page should contain ${topic}
  • 26. “The first principle is that you must not fool yourself - and you are the easiest person to fool.” Richard Feynman
  • 27. Test runners ● unittest testrunner ● zope.testrunner ● pytest-testrunner ● gocept.pytestlayer A test runners is a component which orchestrates the execution of tests and provides the outcome to the user. ● collects tests ● presents outcome ● interact with other tools (e.g. coverage)
  • 28. Test invocation tools ● Command line ● Continuous Integration Servers ● tox
  • 29. Test invocation tools ● Command line ○ python setup.py tests ○ python -m unittest test_module.TestClass ○ python -m pytest tests ○ bin/test (zc.buildout script generated by zope.recipe.testrunner)
  • 30. ● Continuous Integration Servers (Linux/MacOS X - Machines) perfect for pure Python tests (Docker containers, Linux/MacOS X) (Windows) Test invocation tools
  • 31. travis-ci example (Plone context - RestrictedPython) language: python sudo: false matrix: include: - python: "2.7" env: TOXENV=docs,lint-py27 - python: "3.6" env: TOXENV=docs,lint-py36 - python: "2.7" env: TOXENV=py27 - python: "2.7" env: TOXENV=py27-datetime - python: "3.4" env: TOXENV=py34 - python: "3.5" env: TOXENV=py35 - python: "3.6" env: TOXENV=py36 - python: "3.6" env: TOXENV=py36-datetime - python: "3.7-dev" env: TOXENV=py37 - python: "pypy" env: TOXENV=pypy - python: "pypy3" env: TOXENV=pypy allow_failures: - python: "3.7-dev" env: TOXENV=py37 install: - travis_retry pip install -U pip setuptools - travis_retry pip install -U -c constraints.txt tox coveralls coverage script: - travis_retry tox after_success: - coverage combine - coveralls notifications: email: false
  • 32. Test invocation tools ● tox - Translate the concept of continuous Integration to local development ○ De facto standard as a local test invocation tool ○ Groups environments, allow to test different Python versions support Fantastic if you use additional helpers: ● pyenv - having multiple Python version ● git-hooks - run scripts on git commands → pre-commit hook
  • 33. tox example (Plone context - RestrictedPython) [tox] envlist = py{27,34,35,36}, docs, lint-py27, lint-py36, coverage, skip_missing_interpreters = False [testenv] usedevelop = True extras = develop commands = pytest --cov=src --cov-report=xml --html=reports/pytest/report-{envname}.html --doctest-glob=*.rst --self-contained-html {posargs} pytest --doctest-modules src/RestrictedPython/compile.py {posargs} setenv = COVERAGE_FILE=.coverage.{envname} deps = -cconstraints.txt pytest-cov pytest-remove-stale-bytecode pytest-html [testenv:coverage] basepython = python2.7 skip_install = true deps = -cconstraints.txt coverage setenv = COVERAGE_FILE=.coverage commands = coverage erase coverage combine coverage html coverage xml coverage report [testenv:docs] deps = -cconstraints.txt Sphinx commands = python -V sphinx-build -b html -d build/docs/doctrees docs build/docs/html sphinx-build -b doctest docs build/docs/doctrees
  • 34. tox example - Linter - enforce Coding Conventions (Plone context - RestrictedPython) [lint] skip_install = true deps = -cconstraints.txt isort flake8 # helper to generate HTML reports: flake8-html # Useful flake8 plugins that are Python and Plone specific: flake8-coding flake8-debugger flake8-deprecated Flake8-print flake8-pytest flake8-todo flake8-isort mccabe # Potential flake8 plugins that should be used: Flake8-blind-except flake8-commas,flake8-docstrings Flake8-pep3101 flake8-plone-hasattr, flake8-string-format Flake8_strict flake8-quotes commands = mkdir -p {toxinidir}/reports/flake8 isort --check-only --recursive {toxinidir}/src {toxinidir}/tests setup.py - flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src tests setup.py flake8 src tests setup.py --doctests whitelist_externals = mkdir [testenv:lint-py27] basepython = python2.7 skip_install = true deps = {[lint]deps} commands = {[lint]commands} whitelist_externals = {[lint]whitelist_externals} [testenv:lint-py36] basepython = python3.6 skip_install = true deps = {[lint]deps} commands = {[lint]commands} whitelist_externals = {[lint]whitelist_externals}
  • 35. The Zen of Python - PEP20 Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. ... Lessons learned from Zope and Plone → we should embrace each tool that helps us to provide a fantastic products
  • 36. My Wishes to better “Best Practices” for Plone ● Adopt tox on all packages ● Switch to a different package structure and enforce that → bobtemplates.plone ○ docs ○ src ○ tests ● detailed and enforced settings for conventions ○ .editorconf ○ setup.cfg → https://github.com/plone/plone_best_practices_discussion