-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Refactor Database Test #104
Conversation
What if I have both and want both to be tested in one run? That's actually how I'm testing locally. |
@samdark With specific ar driver on each test, the only thing we need is to run the test twice (with different config) :) This PR can avoid huge duplication at the test-side, since we will mainly test the unified layer API, rather than each driver, right? This schema is actually also used by Rails : https://github.com/rails/rails/blob/master/.travis.yml#L10 But the call is yours. |
Check how I've solved the same issue for cache tests. |
I agree that for I think testing database would still need separate config, because : |
Not completely duplicate, just use inheritance... I think the approach of running as many tests as possible is preferred. That's what tests are for, right? |
Yes, running as many test as possible is preferred. But running duplicate test isn't. |
It's not duplicate. Database backend is different. |
Current But, i will wait for some base code to work with, from you or the other, for this one. |
Isn't there a possibility to configure the test suite in a way that it executes the the DbTest several times with different configurations? Basically, testing against an interface is a very good idea imo. But if it results in having to run the test suit several times, probably with changing config in between, it's a no-go. |
Travis is fine but we're using it ourselves locally as well and we want to run it once so it will do all the tests in a single run. |
@qiangxue Yes, i'm looking in that. I want to begin from tests and do it. At this time I want to properly organize tests and look like here important question. Now ActiveRecordTest extends \yiiunit\MysqlTestCase and in future looks like all tests of application logic will depends on database. To migrate appliction from database to another we will need to modify all such tests in projects to use another $Database$TestCase. It seems not very good. But run all tests in single run is also important. |
@rusmaxim yes. I think it's simpler than defining multiple test suites, environments etc. The only thing to look for is an opportunity to decouple tests from Application by creating DB connection yourself. |
@samdark I think most tests with using database in real projects not depends which database using. Do we need DatabaseTestCase anyway, or not? |
@rusmaxim in the ideal world it's true but we still need to test agaist all these databases. |
@samdark I'm about real application testing, not framework testing. So for example in blog application we will use \yiiunit\MysqlTestCase for tests? |
We can probably create a abstract class MyTest extends DbTestCase
{
...
}
class MySQLConnectionTest extends MyTest {
public getDbConnection()
{
return // mysql connection
}
} This way we have a chance to expand test to more DBs easily and to override specific tests if needed. |
Merged PR #202. |
Changes Unknown when pulling 4e8dc33 on toopay:patch into * on yiisoft:master*. |
Since we already have the
env
configuration, now its pretty easy to follow those schema rather than having to createSqliteTestCase
,PostgresTestCase
and so on, for each database driver we want to test.DatabaseTestCase
would pick-up different configuration based by loaded environment (mysql
as default).After this, anyone could get started to work with #15.