Open Development

Automated Testing
Igor dos Santos Montagner ( igorsm1@insper.edu.br )
Igor Montagner License CC BY-NC-SA 4.0

Professional Project

  • Code Quality
    • Linting - Formatting and Common Errors
  • Documentation
    • User
    • Developer
Igor Montagner License CC BY-NC-SA 4.0

Professional Project

  • Code Quality
    • Linting - Formatting and Common Errors
    • Does the code work?
  • Documentation
    • User
    • Developer
Igor Montagner License CC BY-NC-SA 4.0

Does my program work?

  • Under what conditions?
  • On which platforms?
  • Which operations are supported?
  • Can I check the result of an execution? If so, is there a reference value?
Igor Montagner License CC BY-NC-SA 4.0

Automated Testing

Idea: Write a program that verifies whether another program responds as expected.

  • Define situations to be tested...
  • And the expected result in each situation.
Igor Montagner License CC BY-NC-SA 4.0

Automated Testing

Doesn't help

  • Reveal new bugs
  • Ensure software is bug-free

Does help

  • Prevent discovered bugs from returning
  • Prevent unintended changes from breaking previously working code.
  • Document in which situations the software works.
Igor Montagner License CC BY-NC-SA 4.0

Automated Testing

  1. Unit Testing
  2. Integration Testing
  3. User Interface Testing
Igor Montagner License CC BY-NC-SA 4.0

Unit Testing

Idea: Given a function, verify whether it returns the expected value for a given set of parameters.

  • Test functions in isolation.
  • Coverage: Percentage of lines of code executed during unit testing.
  • Serves as function documentation
Igor Montagner License CC BY-NC-SA 4.0

Unit tests - pytest

Igor Montagner License CC BY-NC-SA 4.0

Integration tests

Idea: Given a set of classes with interdependencies, verify that they work well together.

  • Tests interaction between objects
  • Possibility of creating mocks, which are fake objects designed to simulate the interaction between multiple objects.
Igor Montagner License CC BY-NC-SA 4.0

User interface tests

Idea: Simulates user actions (clicks, data entry, etc.) and checks if the expected output is displayed on the screen.

  • Must be designed as minimally specific as possible
  • Most faithful to a user's actual use
Igor Montagner License CC BY-NC-SA 4.0

User interface tests

Selenium

Allows you to create scripts that interact with a web page, performing data entry, scrolling, and clicks. Each assert can be made with the content of a page object.

Igor Montagner License CC BY-NC-SA 4.0

What do I need to test?

Igor Montagner License CC BY-NC-SA 4.0

What do I need to test?

Nobody knows...

Igor Montagner License CC BY-NC-SA 4.0

Practical activity: Tested and approved

Objective: First experience with automated code testing.

"metadata": {"url": "acceppted PR", "group": [ "the same of class 6" ]}

Igor Montagner License CC BY-NC-SA 4.0