-
-
Notifications
You must be signed in to change notification settings - Fork 835
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
Set up PHP testing framework and write initial tests #3
Comments
Codeception is pretty beginner friendly in the testing regards and offers support for unit/functional/acceptance testing (all powered under the hood by PHPUnit). You might want to look into behavior-driven development, I've found that (unit) test-driven development can be a bit pedantic when you're still discovering and knowledge crunching the domain. |
Codeception is pretty good unit testing framework and is also very beginner friendly. I started with codeception when i was teaching myself about unit testing in Laravel apps. I usually try to pair unit testing (for testing modules in an isolated manner) and Integration Testing to test the entire app and the database integration as a whole. I've found that following the repository pattern has made it easy to write test friendly code. For integration testing i've used a tool called Testdummy. |
Starting to dive into this now. Just want to clarify: I should be writing unit and integration tests for the Flarum/Core layer (the domain), and functional tests for the API layer, yes? Will acceptance tests be useful for testing the API (I can't imagine how they would differ from functional tests in this case?) Also, is it worth considering using a combination of Codeception for functional/acceptance testing and PHPSpec for unit/integration testing? PHPSpec's syntax seems a bit nicer in this regard, although I'm all for keeping the tooling as simple as possible. |
OK so I've made a start based on https://github.com/Codeception/sample-l4-app and I have a few more questions/thoughts:
|
I'd be interested in helping with writing tests. It is what I do in my day to day job - testing software/hardware though I'm not familiar with the Codeception framework. |
@tobscure well, here is my experience on testing EmberJS app + backend. I have acceptance tests running in Karma (see EmberJS docs). They test all user interactions and user interface. They run much faster than acceptance tests with Selenium, they also work well with async. I don't use Fixtures provider, instead I use real API calls to backend. Sure I perform cleanup after each test (this is done by API calls too). API is tested with functional tests. I'd recommend to use Laravel4 module. Unit tests are written as usual. Sure, there should be frontend and backend unit tests.
Yes, it is supposed to. I don't have an idea why not. If you are running it as part of acceptance testing, Laravel4 module may not connect to database to start a transaction. Anyway, Laravel4 is supposed to handle your primary database connection and turn it into transaction. Please show me your config, so I could say something for sure |
@DavertMik Thanks for the info. I sorted out the transaction issue — turns out a couple of the database tables were MyISAM instead of InnoDB (for fulltext support). Switched them to InnoDB for now, but I guess we'll eventually need fulltext support at least on the posts table... |
MyISAM is always not a good idea to use. For full text search better to use 2015-01-22 2:34 GMT+02:00 Toby Zerner notifications@github.com:
|
relying on Elastic or Sphinx would remove the ability for this to be hosted on most shared or cloud hosting providers, as they are commonly not included. |
Yeah. Of course there will be a range of adapters for search - including MyISAM fulltext, Elastic, Sphinx, etc. I suppose we'll just manually purge the testing database before/after the tests for the fulltext adapter. |
Once we have tests, this commit should be reverted again so that Travis runs our unit tests on all important PHP versions. |
Also, for Travis: We need to consider testing against lowest and highest dependencies. |
I've used PhpSpec to create a first test now. :) @tobscure Can you set up Travis for the private repo? |
@franzliedke Sorry, Travis costs money for private repos :( |
Ah, true, forgot about that. Never mind me then ;) |
Also, we can enable the Composer cache. |
Closing in favour of flarum/issue-archive#424 |
Install Composer dependencies with --prefer-dist.
When building this foundational prototype, I neglected to learn how to write tests in the interest of time. However, I realise that tests will be extremely important for the longevity of the project, and I am very keen to adopt a test-driven development approach for Flarum.
I personally need to read up properly about how to actually write and use tests in PHP/Laravel. If anyone would be willing to discuss/set up the necessary testing frameworks (again, I'm pretty uneducated as to what is what - unit? behavioural? acceptance?) that would be great. Don’t worry, I will be making an effort to learn soon!
The text was updated successfully, but these errors were encountered: