43
Testing for the Brave and True

Testing for the Brave and True · The code for which you or your team is responsible Automated tests are living documentation ... Runs at the browser level Tests your site like your

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Testing for theBrave and True

github.com/gabesullice

[email protected]

Gabe SulliceBackend Engineer

drupal.org/u/gabesullice

@gabesullice

A little context.

What exactly is thisautomated testing thing?

Automated tests arejust code.

We all test.

“Your code”● The code for which you or your team is responsible

The many ways that we all test● In the browser● With XDebug● With dpm(), var_dump() or print● By reading code

Why all test.

Don’t throw your work away.

“Your code”● The code for which you or your team is responsible

Automated tests are living documentation● You encode your assumptions● They document context

Why do we test?

“Your code”● The code for which you or your team is responsible

Why do we test?

How can these tests make me more productive when it means writing

more code?

“Your code”● The code for which you or your team is responsible

Why do we test?

How can I find the time to write tests?

“Your code”● The code for which you or your team is responsible

Why do we test?

How do I justify it to my client?

“Your code”● The code for which you or your team is responsible

Why do we test?

How do I convince myself?

“Your code”● The code for which you or your team is responsible

Why do we test?

How can these tests make me more productive when it means writing

more code?

“Your code”● The code for which you or your team is responsible

Why do we test?

How can I find the time to write tests?

“Your code”● The code for which you or your team is responsible

Why do we test?

How do I justify it to my client?

“Your code”● The code for which you or your team is responsible

Why do we test?

How do I convince myself?

How do I get started?

Tooling

“Your code”● The code for which you or your team is responsible

The Tools

PHPUnit / Behat

“Your code”● The code for which you or your team is responsible

PHPUnit● Runs at the PHP level● Doesn’t need a browser or browser driver● About testing your code in isolation● Generally faster than Behat

Why do we test?

“Your code”● The code for which you or your team is responsible

Behat● Runs at the browser level● Tests your site like your QA person or your client would

test your site● Tests your whole stack● Slower than PHPUnit

Why do we test?

“Your code”● The code for which you or your team is responsible

“Your code”● The code for which you or your team is responsible

PHPUnit● Comprised of two things:

○ \PhpUnit\Framework\TestCase○ A command-line tool

The Tools

“Your code”● The code for which you or your team is responsible

Drupal-isms● Unit/Integration Tests

○ \Drupal\Tests\UnitTestCase○ \Drupal\KernelTests\KernelTestBase

● Functional Tests○ \Drupal\KernelTests\KernelTestBase○ \Drupal\simpletest\WebTestBase○ \Drupal\Tests\BrowserTestBase

Concepts

Set up.