You are about to follow a 3 minutes end to end tutorial to show you how to use Ponicode to detect bugs, prevent regressions, increase your code quality and coverage by generating unit tests All this tutorial is available on this video HERE
If you have not installed our extension do it for free in the VSCode Marketplace.
Ponicode uses a runner to verify that your tests pass. For this you should verify that needed packages are installed.
If not already done just enter this command in the javascript
folder
cd path/to/demo-project/python
bash setup.sh
- Open the a_basics.py file
- Click in the body of the function
calculate_commission_py
- You should see two decorators appearing above your function
Ponicode:Flash Test
andPonicode:Unit test
- Click on
Ponicode:Flash Test
- Et voilà! You should see 5 to 6 test cases generated including happy paths and edge cases
- Flash test takes care of the most tedious part of testing: Syntax and testing multiple scenario
pytest
:) If you want lines visualization for Python send us a message in our community slack
- Open the a_basics.py file
- Click in the body of the function
get_client_age_generation_py
- You should see two decorators appearing above your function
Ponicode:Flash Test
andPonicode:Unit test
- Click on
Ponicode:Unit test
- An interface will open on the right with two sections
Unit tests
andSuggestions
. SectionUnit tests
represents all your existing test cases. SectionSuggestions
is a list of representations of test cases that Ponicode's AI engine thinks you should pick from to increase your code quality. - You can click the toggle button next to the settings button to get asssertions on expected values and see coverage information
- The
Suggestions
are then filtered by coverage gain. Each time you click on + for a suggestion, you are generating a test in your test file.
Prevent regressions and bugs with Ponicode Unit test (example in Javascript and you can do it the exact same way in Python)
- Go in Javasript folder
- Install the dependencies
cd path/to/demo-project/javascript && bash setup.sh
- Open the departments.js file
- Click in the body of the function
get_and_validate_department
- You should see two decorators appearing above your function
Ponicode:Flash Test
andPonicode:Unit test
- Click on
Ponicode:Unit test
- An interface will open on the right with two sections
Unit tests
andSuggestions
. SectionUnit tests
represents all your existing test cases. SectionSuggestions
is a list of representations of test cases that Ponicode's AI engine thinks you should pick from to increase your code quality. - You can click the toggle button next to the settings button to get asssertions on expected values and see coverage information
- The column
throws with message
is filled with a value for the inputundefined
. This is because Ponicode provides edge cases to see abnormal behavior. Here, a potential bug is detected. This is early bug detection. - Let's say this early bug is actually a real bug. Just add a few lines of code so there is no throw message anymore.
- Add your test to protect you against a potential bug in the future
- Add a few
Suggestions
- A regression is a function that is not behaving like it is suposed to anymore.
- Try to change the code, for example the return value in the body of the function. Ponicode will instantly tell you with a red x which test is now failing, pointing to a regression.
- Just change the value back to what it was and see the test passing again to correct that regression.