-
Notifications
You must be signed in to change notification settings - Fork 62
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
Annotations to opt-out per test class and test method #171
Comments
So out of interest I just benchmarked this. The test case: use PHPUnit\Framework\TestCase;
class FooTest extends TestCase
{
/**
* @dataProvider dataProvider
*/
public function testNothing(int $foo): void
{
}
public function dataProvider(): \Generator
{
foreach (range(0, 100000) as $i) {
yield [$i];
}
}
} With the extension (and roll-back) of this bundle enabled:
And now without the extension (and thus roll-back) enabled:
|
Actually the test above was not valid since no DB connection was ever created. Will have a look at a proper benchmark later today |
Ok here a proper benchmark now with 2 tests where the first one actually creates a DB connection and makes sure the roll-back logic kicks in: namespace Tests\Foo;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class BarTest extends KernelTestCase
{
public function testBar(): void
{
self::bootKernel()->getContainer()->get('doctrine')->getConnection()->executeQuery('SELECT 1');
}
} namespace Tests\Foo;
use PHPUnit\Framework\TestCase;
class FooTest extends TestCase
{
/**
* @dataProvider dataProvider
*/
public function testNothing(int $foo): void
{
}
public function dataProvider(): \Generator
{
foreach (range(0, 100000) as $i) {
yield [$i];
}
}
} Now it looks a bit different: With extension: So the performance penalty for 100k tests is roughly 12s for me. |
Thank you so much for these! Indeed that does not look to worth the effort. I will do some benchmarks on my side too 👍 |
I did the same benchmark and I have 40 to 45 seconds of penalty for 100k tests. Don't know why we have so much difference. Anyway, it still does not worth the effort to my eyes. Feel free to close the issue or not 👍 |
Ok thanks 👍 I'm closing this for now as I also don't think its worth the effort for now. |
Hello !
What do you think about an annotation that can disable the begin transaction/rollback of the phpunit extension ?
At the moment I am running a lot of test that don't require any database query or are just read-only but the extension is still triggered.
Cheers!
The text was updated successfully, but these errors were encountered: