Codeception / Codeception

Full-stack testing PHP framework
http://codeception.com
MIT License
4.76k stars 1.3k forks source link

Running tests from an installed package - Laravel 4 #1887

Closed austenc closed 9 years ago

austenc commented 9 years ago

I'm using laravel 4 and codeception 2.0.9 at the time of writing. I have several apps that all utilize the same (private) package. This package acts as a foundation in each app and is meant to be extended. So basically you create a laravel app, utilize our private package, and customize as needed for each scenario. What I'd like to be able to do is run the tests from the installed package and the tests from my outer (main) app. Without this, we won't be able to tell whether an override / extension of the code has broken some core function or not.

So I've got something like this

app
bootstrap
...
tests
    - codecept folders here and some 'extension of functionality' tests

...

vendor
    - austenc
        - mypackage
            - codeception.yml
            - tests (usual 'unit', 'functional', etc... folders in here)

So, I'd like to run my tests down in the vendor folder, but also keep a few additional (per client) tests in the /tests directory. I've looked at the documentation and tried several things at this point:

include:
    - vendor/austenc/mypackage

In terms of a solution, one idea is to make the Laravel 4 module a little bit 'smarter' about whether it's in the vendor folder or not. It appears (a couple lines up in the Laravel4 module source I linked) that similar consideration is already made for the workbench. If this is something that would get merged I am happy to dig into it and submit a pull request. I was hoping to get others opinions and make sure I'm not missing something prior to working up PR. Let me know if I can clarify anything about my scenario or if there's another solution someone has in mind. Thanks!

I'm hoping to get some feedback and/or have a discussion about running tests that exist in an installed package in the vendor folder.

janhenkgerritsen commented 9 years ago

A good implementation would definitely be considered for a merge. I have to admit that I do not develop Laravel packages and so I don't have a good read on what is required for testing. And currently I lack the time to look into it.

Maybe PR #1782 may be of interest for this problem? This PR makes the path of the workbench directory configurable in the Laravel 5 module. Is that something that would fix your problem if it was implemented in the Laravel 4 module? Or do you need something else?

austenc commented 9 years ago

It seems like it would, thanks for the comment @janhenkgerritsen. What I've ended up doing for now is just using grunt to publish the tests from my vendor/whatever/package folder to the main tests directory and am just not keeping them under version control. I will try to implement the solution from PR #1782 in my scenario and if it works I'll be happy to submit a new PR to the Laravel 4 module if needed.

janhenkgerritsen commented 9 years ago

Ok thanks. Hopefully it fixes your issue.

janhenkgerritsen commented 9 years ago

If someone wants to implement this enhancement I will merge it, but I wont implement it myself. I will only implement new features for the Laravel5 module and not for the Laravel4 module, since Laravel 5 has been released for a while now.