Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:50:13+00:00 2026-06-07T23:50:13+00:00

I have recently become involved with some TDD using PHPUnit. I have to test

  • 0

I have recently become involved with some TDD using PHPUnit.
I have to test a database-driven app, and read about the DbUnit extension, which I was planning to research and implement over the coming weeks.

However, I have come across this presentation by the man himself – Sebastian Bergmann – He has a slide entitled ‘Avoid testing against MySQL if you can’, which has cast some doubts upon my escapade.

Can someone explain the reasons why I should not test against MySQL?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:50:16+00:00Added an answer on June 7, 2026 at 11:50 pm

    Two reasons:

    • it is slow (and unit tests need to be fast)
    • it adds extra failure point that is beyond your control (does test really fail when DB connection fails?)

    Instead, as author suggest you should test your DAL with in memory databases, like SQLite. This eliminates problems noted above.

    However, this approach has its drawbacks too – you might have problems porting SQL from one database dialect to SQLite. This naturally means you won’t be able to test MySQL specific parts of your DAL. As always, it is double edged sword – you get unit test speed and isolation, but you lose credibility (if we can call it this way) – if it passed on SQLite, can you be 100% sure it works on MySQL?

    It might be not that bad idea to leave the core of your DAL/DAO tests to integration testing phase, where you will test them agains real DB engine you use and leave small things for unit testing; for example mappings (if you use ORM that is).

    Edit: the fast is by no means strict requirement – it’s just good general advice. When doing TDD your developers will run unit tests a lot (think this way; every commit to local repo/every important code change will require code base integrity check by running unit tests) – perhaps not all of them, but surely some. You want this process to be quick.

    Now, having slow tests usually ends like this:

    • “Man, this things runs so slow…”
    • “Perhaps I can run just few of them… I’ll run rest later”
    • At this point we know later never comes
    • “Hey, my last commit didn’t break anything and I didn’t run any tests at all!”
    • “Why would I run them after all?”

    Writing tests that are not run, pretty much kills the purpose of writing them.

    This thing happened to a friend who works with me; his team had test suite running +/- 20 minutes (DAL tests done poorly, IoC container involved in tests), developers started running some tests, and pretty soon the “Current build breakers” emails became daily thing. They had rather large suite, but breaking test was not that bad.

    Overall, your approach seems correct – I wouldn’t move tests to SQLite. Like I suggested, have database layer tested with integration tests suite (so that it can be run separately than regular, unit tests suite).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently read topics about memory fragmentation: How to solve Memory Fragmentation and
I have recently began using C# to invoke powershell scripts, with some success :)
I have recently become a T4MVC fanatic and now I seem incapable of using
I have recently become interested in the field(s) of data mining and machine learning.
I have recently started using Netbeans with following stack Liferay, icefaces with jBoss. Is
I have recently become an intern on a startup online classroom system. So now,
I have recently become a teaching assistant for a university course which primarily teaches
Recently, I have become increasingly familiar with Django. I have a new project that
Recently our WPF/Entity Framework 4.0 application has become unstable after we began using backgroundworkers
I've recently set some coursework for some undergraduate students for which they have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.