Giter Club home page Giter Club logo

tests_demo's Introduction

Test Project

Run Unit Testing Badge Badge Badge

About

This is a test demo project for experiments with CI integration, test reports, and metrics from testing.

QA Community - https://t.me/AutomationUA (Tests are written by people)

CI/CD Integrations Example (We took 2 CI systems just to compare)

Jenkins:

GitHub Action:


Unit Testing

Unit Testing Best Practices:

1️⃣ Coverage:

  • The main metric for unit tests. (How many percent of the code is covered by tests.)
  • It should always be calculated and visible.
  • In my case, coverage is 96.49%.
  • Please add a badge to the repository if possible. It's very important to see coverage WITHOUT diving into build logs 🙏

2️⃣ Mocks:

  • Mocks are often used in unit tests. To check the interaction with an external service without actually calling that service.
  • I added an example. (Example Mocked Service Test)

3️⃣ Very important:

  • Break the code and check that the test fails. Because if you've covered the code with a test, broken the code, and the test is green, then you're doing something wrong.

API Testing (Example with Trello API)

API Testing Best Practices

  • Always consider NOT updating ALL tests with the slightest changes in the code.
  • Avoid making requests directly in the tests to prevent duplicate code (noise).
  • Instead of returning just a JSON response in the test, parse it into an object.

Example: 🙏

**Here we created a separate class responsible for sending requests. And all the logic of the Trellо API


Grafana For Metrics from Testing (In Progress)

Of course, when a project is small and the team is small, metrics may not be needed. But when the team is large and there are many tests, we need to understand how long each test takes, which tests are flaky, and which errors occur in which tests.

I really love DataDog, and we had it in our company, so it was easy to set up there. https://safo-bora-katerina.blogspot.com/2024/02/datadoggrafana-and-metrics.html

Now I took Grafana as an example to experiment with it.

What were we interested in?

  • We were interested in which tests were the longest.
  • How often do we run tests per day (since we knew how much an hour of CI costs and it was important for us to understand the time).
  • How long do we wait for the build (and all tests).
  • The number of tests at each level (unit, API, end-to-end, etc.)
  • PASSED/FAILED/SKIPPED.
  • Whether there are flaky tests? Which ones specifically?
  • Whether we rerun tests, and how many times?

tests_demo's People

Contributors

safo-bora avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.