Using Mix to Run Phoenix Tests

Whether you knew it or not, Phoenix has already been generating default tests for you, such as test/controllers/video_controller_test.exs. We can go ahead and remove that file since it’s built for generic REST actions, not the features we’ve specifically built into our controller. We’ve added user authentication, validations, and the like to our videos, so we’ll start fresh with our VideoController tests. Delete the test/controllers/video_controller_test.exs file now, and then let’s see where our test suite stands:

 $ ​​mix​​ ​​test
 ...
  1) test GET / (Rumbl.PageControllerTest)
  test/controllers/page_controller_test.exs:4
  Assertion with =~ failed
  code: html_response(conn, 200) =~ "Welcome to Phoenix!" ...

Get Programming Phoenix now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.