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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the _generated folder before writing a .gitignore file there #4449

merged 1 commit into from Aug 21, 2017


None yet
2 participants

nstapelbroek commented Aug 14, 2017

Hi there 馃憢

After following the setup guide on a fresh project I got hit with a warning:

$ ./vendor/bin/codecept init api
Let's prepare Codeception for REST API testing

? Where tests will be stored? (tests) 
? Start url for tests (http://localhost/api) 
PHP Warning:  file_put_contents(tests/_support/_generated/.gitignore): failed to open stream: No such file or directory in /home/nico/Projects/myawesomeproject/vendor/codeception/codeception/src/Codeception/InitTemplate.php on line 204
> Created test directories inside at tests
> Api helper has been created in tests/_support/Helper
> ApiTester actor has been created in tests/_support
> Actions have been loaded
> Created global config codeception.yml inside the root directory
> Created a demo test ApiCest.php


Next steps:
1. Edit tests/ApiCest.php to write first API tests
2. Run tests using: codecept run

Happy testing!

To prevent this error, I came up with two solutions:

  1. Create the directory before it exists
  2. Patch thegitIgnore() method so it checks if the path exists before writing the file.

Approach 2 seemed more ideal but might break other logic since I don't know why the statement in exists. Why is it testing if we have a .gitignore in our project root? To prevent confusion I've picked solution 1.

I'd love to know if you have any feedback on the PR. Thanks for Codeception 馃殌


This comment has been minimized.

Show comment
Hide comment

Naktibalda Aug 21, 2017


Thanks, this solution is good enough.


Naktibalda commented Aug 21, 2017

Thanks, this solution is good enough.

@Naktibalda Naktibalda merged commit c59f541 into Codeception:2.3 Aug 21, 2017

3 of 4 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
continuous-integration/appveyor/pr AppVeyor build succeeded
semaphoreci The build passed on Semaphore.
wercker/build Wercker pipeline passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment