How to run single test method with phpunit?

前端 未结 13 2170
猫巷女王i
猫巷女王i 2020-11-30 16:13

I am struggling to run a single test method named testSaveAndDrop in the file escalation/EscalationGroupTest.php with phpunit. I tried

13条回答
  •  时光取名叫无心
    2020-11-30 17:07

    • Run this inside your project root directory i am using in laravel root directory.

    vendor/bin/phpunit --filter 'Your method name'
    

    Example with custom method name.

     /** @test //Initilize this for custom method name, without test keyword
      *  
      * Test case For Dashboard When User Not logged In it will redirect To login page
      */
      public function only_logged_in_user_see_dashboard()
      {
        $response = $this->get('/dashboard')
                       ->assertRedirect('/login');
      }
    

    Example with test keyword

    /**
    * A basic test example.
    *
    * @return void
    */
     public function testBasicTest()
     {
      $this->assertTrue(true);
     }
    

提交回复
热议问题