Assuming you are using PHPUnit to write integration tests, the first step is to make sure your environment is correctly configured.
For that you will need to have an empty database in place and use the correct PHPUnit configuration file.
Integration Test Environment Setup
To specify the credentials for the test database use this file:
And the phpunit configuration file can be found in the following path:
Running Integration Tests
Once you have your test environment configured you are ready to create your first test.
I think nothing stops you from put them anywhere but usually your tests go into:
Integration test examples
For integration test examples I tend to look at:
There are many examples of integration test for blocks, controllers, models, etc.
A good and simple example is this
* Contact index controller test
class IndexTest extends \Magento\TestFramework\TestCase\AbstractController
public function testPostAction()
$params = [
'name' => 'customer name',
'comment' => 'comment',
'email' => 'firstname.lastname@example.org',
'hideit' => '',
"Thanks for contacting us with your comments and questions. We'll respond to you very soon."
For more information take a look at this link:
Hope it helps.