Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Explained how to run tests in multiple kernel apps #8124

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

Closed
wants to merge 2 commits into from

Conversation

javiereguiluz
Copy link
Member

This fixes #6279.

:class:`Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase` class. Inside that
class, a method called ``getKernelClass()`` tries to find the class of the kernel
to use to run the application during tests. The logic of this method does not
support multiple kernel applications, so your tests won't use the right kernel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful here. The approach described here does not solve the issue when you have more than one kernel. The problem then still is that the KernelTestCase class keeps a reference to the previously created kernel in its static $kernel property. Thus, if your functional tests do not run in isolated processes a later run test for a different kernel will reuse the previously created instance which points to a different kernel.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! You are right and this is critical. What would be the best (and simplest) solution to this problem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be sufficient to always reset the static $class property inside the tearDown() method:

protected function tearDown()
{
    parent::tearDown();

    static::$class = null;
}

The parent::tearDown() call is important to make sure that the kernel is shut down after the test was run.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! I've fixed the code and reused your original explanation because it's great.

@xabbuh xabbuh added this to the 2.7 milestone Jul 10, 2017
@xabbuh
Copy link
Member

xabbuh commented Jul 11, 2017

Thank you Javier.

xabbuh added a commit that referenced this pull request Jul 11, 2017
…reguiluz)

This PR was squashed before being merged into the 2.7 branch (closes #8124).

Discussion
----------

Explained how to run tests in multiple kernel apps

This fixes #6279.

Commits
-------

9507964 Explained how to run tests in multiple kernel apps
@xabbuh xabbuh closed this Jul 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.