Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that test has been really run #32

Closed
milo opened this issue Jul 18, 2013 · 8 comments
Closed

Ensure that test has been really run #32

milo opened this issue Jul 18, 2013 · 8 comments

Comments

@milo
Copy link
Member

milo commented Jul 18, 2013

Sometimes can happend that none assertion is done in a test file, e.g. accidental die() before first assertion or just:

class MyTest extends TestCase {
    function testFail() {
        Assert::fail('FAIL');
    }
}

# and there is missing (new MyTest)->run();

... test seems to be passing.

First idea is to count Assert::method() calls, check it in the shutdown function and fail or skip the test. The plus can be nothing-saying statistics :)

@dg
Copy link
Member

dg commented Jul 18, 2013

Missing (new MyTest)->run(); is real problem. Tester was not designed for this usage. But now we have TestCase and it should be somehow solved. Probably by Runner (auto_append_file? or use special loader.php and pass test name as argument?).

Calling assertions seems like good idea.

@fprochazka
Copy link
Contributor

Having it runned by auto_append_file is a good idea, but you cannot auto_append_file, when you run the test directly, not through runner.

@JanTvrdik
Copy link
Contributor

That can be done using http://php.net/manual/en/configuration.file.per-user.php, by I've never tried it.

@dg
Copy link
Member

dg commented Jul 19, 2013

Why so complicated? -d auto_append_file=file.php works well in current Tester.

@dg
Copy link
Member

dg commented Feb 3, 2014

Missing (new MyTest)->run(); is solved by 96b192c.

@milo
Copy link
Member Author

milo commented Feb 3, 2014

@dg Yop. If you think that checking ordinary tests (not TestCases) is not need it, close it please. Personaly I would check ordinary tests too.

@dg
Copy link
Member

dg commented Aug 14, 2014

The only one case which is not checked is when you forget to call Tester\Environment::setup(), isn't it?

@milo
Copy link
Member Author

milo commented Aug 14, 2014

Yes.

@dg dg closed this as completed Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants