14

I'm pretty new to both Laravel and PHPUnit, and I'm using Laravel 4 on Ubuntu 12.04.

When I run phpunit from my project's home directory, it runs the ExampleTest.php test that comes with Laravel. I created my own sample test (exactly like their example and in the same directory, only the file and test are renamed and do something different), and ran phpunit again like before; but it still only ran ExampleTest.php--not my created test. But if I run phpunit path/to/myTest, it runs my test just fine. So I feel like this is a dumb question, but how do I run all of the tests with one command (I thought phpunit should've done that)?

Thanks for the help!

2
  • what is the actual 'path/to/myTest' and the test filename? Commented Jul 30, 2013 at 0:46
  • app/tests/TestCreateEvent.php Commented Jul 30, 2013 at 0:54

1 Answer 1

37

Your tests need to finish with ...Test.php to run automatically. So change

app/tests/TestCreateEvent.php

to

app/tests/CreateEventTest.php

and it should work.

Also make sure you rename the model inside the test to "class CreateEventTest extends TestCase"

Sign up to request clarification or add additional context in comments.

3 Comments

I figured it was something simple. Thanks!
One question, why does TestCase work? Its not ended with Test.php
TestCase has no tests. each test method must be prefixed with "test". testSomething() {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.