代码之家  ›  专栏  ›  技术社区  ›  Toma Tomov

昨天工作的PHPUnit cahces功能

  •  0
  • Toma Tomov  · 技术社区  · 7 年前

    我在20小时前开始使用phpunit。我昨天写了一些测试,现在看起来它们被缓存了。例如,这是我的3个测试:

    public function test(){
            $this->url("index.php");
    
            $username = $this->byName('username');
            $password = $this->byName('password');
    
            $this->assertEquals("", $username->value());
            $this->assertEquals("", $password->value());
        }
    
        public function testLoginFormSubmitsToAdmin()
        {
            $this->url("index.php");
    
            $form = $this->byCssSelector('form');
    
            $action = $form->attribute('action');
            $this->assertContains('admin.php', $action);
    
            $this->byName('username')->value('jeffry');
            $this->byName('password')->value('123456');
            $form->submit();
    
            $welcome = $this->byCssSelector('h1')->text();
    
            $this->assertRegExp('/(\w+){5}/i', $welcome);
        }
    
        public function testSubmit()
        {
            $this->url('index.php');
            $this->assertFalse($this->byId('submit')->enabled());
    
            $this->byName('username')->value('Az');
            $this->byName('password')->value('1234567');
    
            $this->assertTrue($this->byId('submit')->enabled());
        }
    

    现在我正在尝试创建新函数,如 public function todayTest(){ ... } 但它没有被执行。当我注释其他测试时,运行 phpunit TestLogin.php 我得到的是:

    PHPUnit 6.5.7 by Sebastian Bergmann and contributors.
    
    Time: 93 ms, Memory: 4.00MB
    
    No tests executed!
    

    好像我的功能不存在。如果我将新创建的函数的名称更改为昨天函数的名称,如- public function test() (将名称更改为 todayTest() test() )它工作得很好。在谷歌周围发布了一些红色帖子,发现了一些关于缓存的信息,但不知道如何清除它们。我能得到一些建议吗?非常感谢。

    P、 我也在使用 Selenium 3.11.0

    1 回复  |  直到 7 年前
        1
  •  2
  •   axiac    7 年前

    现在我正在尝试创建新函数,如public function todayTest(){…}但它没有被执行。

    它不起作用,因为它没有按照PHPUnit遵循的规则命名。

    这个 documentation of PHPUnit 解释如何命名文件、类和方法:

    1. 这些测试是名为 test*

      或者,您可以使用 @test 方法docblock中的注释,以将其标记为测试方法。

    因为您可能不使用 @test annotation ,方法 todayTest() 不是测试,而是助手方法。将其重命名为 testToday() PHPUnit将运行它。