Testing

Testing

Make sure code behaves as expected.

Testing and test-driven development is an important part of professional coding. Our IDEs come with a friendly user interface for writing and running tests, using a variety of frameworks.

See Also

JetBrains Blog

pytest vs Unittest, Which is Better?
Python, being a versatile and widely used programming language, offers several testing frameworks to facilitate the testing process. Two prominent choices are pytest and unittest, both of which come with their own sets of features and advantages.

Part of tutorial

Testing and debugging
Testing and debugging in IntelliJ IDEA

YouTube

Do you do enough testing? pytest to the rescue!
Join us to learn how you can use pytest to find bugs, improve code quality, and even have some fun along the way.

JetBrains Blog

An Interview with Brian Okken - the pytest storyteller
Brian wears many hats including being a host for multiple Python podcasts and the author of Python Testing with pytest and has recently launched his new pytest course. Mostly, Brian spends his free time telling people they should write good, clean automated tests, specifically using pytest.

YouTube

Productive pytest with PyCharm
Testing is a major part of Python development and pytest has become the leading testing framework. Brian Okken, author of the recent book Python Testing with pytest and host of the Test and Code podcast, helps you “level up” your pytest skill.

JetBrains Blog

Three pytest features you will love
One of the most popular frameworks for Python is pytest, and it comes with several cool features. I’m going to show you three of them in this blog post.

tip

Show diff for failing test
Quickly see the diff for failing test

tip

Generate a Test Class
Generate a new test class from your Java class

tip

Navigate to Test
Go to your matching test class

playlist

Highlights of GoLand 2023.3
Explore key features and enhancements in GoLand 2023.3.

tip

Code coverage for applications
Track code execution and identify dead code effectively

Part of tutorial

Unit testing
The Unreal Engine testing framework is built in and works without additional configuration.

Part of tutorial

Unit testing
What is RiderFlow? And where to find it?

tutorial

Marco Codes - Hibernate & JPA Tutorial
Crash course in Hibernate and JPA

tip

Generate tests for generic functions
Use a shortcut to generate test files for your generic functions.

tip

Integrated Go Playground
You can format and share your code, change the Go version, and run your code using the Go playground server.

tutorial

Marco Codes - JUnit 5
JUnit 5 Nice n Easy

tip

Merge/Unmerge If Statements
Experiment with your code without changing the semantics

tip

Fuzz testing
Automate your tests by continuously submitting various input.

tutorial

React, TypeScript, and TDD
How to write React applications in TypeScript using TDD, highlighting features of the IDE

tutorial

Using the Terminal in IntelliJ IDEA
IntelliJ IDEA has a built-in terminal that you can use to perform a number of functions inside your IDE

tutorial

Migrating JUnit 4 to JUnit 5
Migrating your JUnit 4 test suite to JUnit 5

tip

Continuous Testing
Run your tests in the background, while you code.

tip

Hot Spots
Find areas of your code base that may need better test coverage.

tip

Generate Test Methods
Generate a test method in your Test class

tip

Detect incorrect usages of t/b.Fatal* calls in goroutines
Find if tests or benchmarks are using t/b.Fatal* calls inside goroutines incorrectly

tutorial

Writing Tests with Spock
Learn about the Spock testing framework by creating a project that uses Spock to unit test Java code

Part of tutorial

Data Pipes
Often we want to test the same set of criteria with different sets of data. Data pipes is one mechanism to do this.

Part of tutorial

Expecting Exceptions
Tests don't check just the happy paths, sometimes we want to say we're expecting a specific Exception.

Part of tutorial

Given, When and Then
See how Spock tests are usually structured.

Part of tutorial

Mocks
Mocks are a useful testing tool. We can provide "empty" objects, so we don't have to initialise the whole application to test a section, and we can use mocks to check our code is making the calls we expect.

Part of tutorial

Setting up the Dependencies
Add Spock framework dependencies to the project

Part of tutorial

Setup and Teardown
See how to set up, or clean up, test classes and methods in Spock.

Part of tutorial

Stubs
Stub objects allow us to state from a test what values get injected into our application code. They can provide simple interfaces, so we don't have to initialise the whole application to test a section.

Part of tutorial

Verify All
Test frameworks often stop the test at the first failure. Find out how to run all conditions to see which pass and which fail.

Part of tutorial

Data Tables
Data tables offer the same functionality as data pipes, but this syntax can sometimes be more readable for more complex sets of data.

Part of tutorial

Writing and Running Unit Tests with ReSharper
Run, debug and profile tests, do continuous testing, and inspect code coverage.

tip

Assert That Import
Use quick intentions to manage imports

tutorial

Writing JUnit 5 Tests
Writing JUnit 5 Tests

tip

Assert completion in testify
Write testify asserts faster thanks to the IDE smartness

tip

Live Template to create a for loop in benchmark functions
Benchmark loops are repetitive, so let the IDE handle this for you

tip

Live Template to write benchmark function
Write benchmarks quicker thanks to the builtin bench live template.

tip

Navigate to subtests in table tests
Jump to the specific test case from the results window

tip

Run a single test from a table test
Focus your testing on new test cases or tests that fail

tip

Completion for testify test names
Let your IDE add constructor arguments to your instance.

tip

Live Template to create test function
Write tests faster thanks to the builtin func Test live template.

Part of tutorial

Testing code
Get started with testing. We will use Jest as an example.

tip

Auto-Run Tests
Get into testing mode by telling GoLand to automatically re-run tests as you type.

tip

Run Single Test
Speed up testing by focusing on one test.

tip

Spot Coverage Gaps Using the Gutter
Let the IDE help you spot coverage gaps in your testing.

tip

Run Tests from Editor
Learn how to run a single test right from the editor.

Part of tutorial

Unit Testing with Rider
Learn how Rider can help make sure code behaves as expected, with continuous testing and code coverage.

tip

Review Errors from Test Runners
In a test file, hover over an error to get more information about it.

tutorial

Visual Testing with pytest
Test writing is productive and fun with PyCharm as a visual testing tool atop pytest.

Part of tutorial

Background on Testing
Introduce testing, pytest, and how it all fits into PyCharm, along with a scenario to work on.

Part of tutorial

Debugging During Testing
When writing tests, use the PyCharm "visual debugger" to interactively poke around in the context of a problem.

Part of tutorial

Test Fixtures
Make your tests more focused by moving sample data to pytest fixtures.

Part of tutorial

Jump to Error
Writing code means writing broken code. Click a link in a traceback to open a file on the line of the error.

Part of tutorial

Skipping Tests
During refactoring, use pytest's markers to ignore certain breaking tests.

Part of tutorial

Hello Test
Write a simple test and run it in PyCharm's visual test runner.

Part of tutorial

Getting Into the TDD Flow
Setup your PyCharm project to help get into the flow of Test-Driven Development (TDD).

Part of tutorial

Project Setup
Make a PyCharm project and virtual environment with dependencies, then configure PyCharm to use pytest.

Part of tutorial

Testing Exceptions
Write tests which ensure exceptions are raised when expected.

tip

Finding Tests in Large Test Files
Use the Structure tool window for quick navigation around large test files.

tip

Navigate to Test
Use the Go to Symbol popup to go to a test.

tip

Speed Up Coverage with Configuration File
Speed up your "visual coverage" with a config file and correct working directory.

tip

Split Screen Without Tabs
Get your code and tests side-by-side without resorting to tabs.

tip

Spot Coverage Gaps Using the Gutter
Let the IDE help you spot coverage gaps in your testing.

tip

Auto-Run Tests
Get into testing mode by telling PyCharm to automatically re-run tests as you type.

tip

Run Single Test
Speed up testing by focusing on one test.