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

HELP! FATAL ERROR. TESTS NOT FINISHED. #1111

Closed
mikeerickson opened this issue Jun 17, 2014 · 5 comments
Closed

HELP! FATAL ERROR. TESTS NOT FINISHED. #1111

mikeerickson opened this issue Jun 17, 2014 · 5 comments

Comments

@mikeerickson
Copy link

@mikeerickson mikeerickson commented Jun 17, 2014

I have been battling this issue for weeks and until now, I have just worked around it (ignored testing this part of application) but I have to face it head on now and dont know what to do.

I am simply trying to perform a simple test POST using API suite.

If there are any suggestions, it would be greatly appreciated!

Error

FATAL ERROR. TESTS NOT FINISHED.
Call to a member function request() on a non-object

Test method causing error

public function it_should_create_new_resource(ApiTester $I)
{
    $I->sendPOST($this->baseUrl().'companies', ['name', 'CodeDungeon'], null);
    $I->canSeeResponseIsJson();
}

api.suite.yml

class_name: ApiTester
modules:
enabled: [REST, ApiHelper, PHPBrowser]
config:
PHPBrowser:
url: http://rangladex.app:8000/
REST:
url: http://rangladex.app:8000/api/v1/

@DavertMik
Copy link
Member

@DavertMik DavertMik commented Jun 20, 2014

Please attach a stack trace of error

@mdwheele
Copy link

@mdwheele mdwheele commented Aug 27, 2014

I get this behaviour when a previous request using the REST module fails, but the suite keeps running. The next time the module is used, the internal client gets into a weird state and is nulled out.

@mikeerickson Do you have a more complete example with stack trace? If not, I'll try and reproduce; though I'm using Specify in my examples. I don't know that this is a "bug" more than it is lack of a good queue to the developer as to what failed. Perhaps (depending on what Mike brings back) this may be impetus to improve error checking in the module to make sure it's in a clean state between tests. Might be hard to do.

As an anecdote, I modified https://github.com/Codeception/Codeception/blob/2.0/src/Codeception/Module/REST.php#L72 to clone the client from the connection module and the error goes away because it forces a new copy of the client to be made every time. Doubtful that this is the cleanest solution and I have no idea where this causes issues, if any.

I'll give it a day and if Mike doesn't respond, I'll put together a small suite demonstrating the issue I've seen related to this using Specify. It just so happens that Specify's "isolated code block" feature brings this issue to light more often whereby a failure in one block leaves the module-level client in an inconsistent / dirty state.

@mdwheele
Copy link

@mdwheele mdwheele commented Aug 27, 2014

I'd also be interested in sending a PR after talking through the issue and with your guidance! 😄

Also, the title of this issue is a little loud and misleading as to what the problem actually is.

@mdwheele
Copy link

@mdwheele mdwheele commented Aug 27, 2014

https://github.com/Codeception/Codeception/blob/2.0/src/Codeception/Lib/InnerBrowser.php#L49 is referenced by the REST module (which retrieves client) and InnerBrowser nullifies its client after a test is complete.

Worded this ambiguously; made some edits. It's late here 😦
On the next run, REST is still holding a valid reference to InnerBrowser's client, but the client is nulled out. By removing the assignment by reference, we're 'cloning' the value of InnerBrowser's client. This comes at the cost of copying InnerBrowser's client on every test, which:

  • Comes at some undetermined computational cost (likely negligible)
  • Possible impact on code reliant on sharing InnerBrowser state between test methods? It looks like InnerBrowser is just a proxy for REST to get access to an implementation of Symfony's browserkit client. Isn't used for much else?

Leaving this alone for now to let Mike pipe up. I don't have a debugger tonight so I can't set breakpoints to give more information, but I'll try to get that together.

zbateson added a commit to zbateson/Codeception that referenced this issue Apr 1, 2015
- Using can/cant causes cleanup code to be called, which causes an
  exception calling subsequent tests: for instance calling canSee()
  followed by amOnPage (or canSee twice).
- Fixes Codeception#1647 Codeception#1354 and Codeception#1111
- Same as pull request Codeception#1807 - but against master and with some added
  test code
zbateson added a commit to zbateson/Codeception that referenced this issue Apr 2, 2015
- Using can/cant causes cleanup code to be called, which causes an
  exception calling subsequent tests: for instance calling canSee()
  followed by amOnPage (or canSee twice).
- Fixes Codeception#1647 Codeception#1354 and Codeception#1111
- Same as pull request Codeception#1807 - but with some added test code
@zbateson
Copy link
Member

@zbateson zbateson commented Apr 2, 2015

Should be fixed now with #1834

@zbateson zbateson closed this Apr 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.