Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If your app relies heavily on using a database, your app naturally integrates with a database then it makes no sense to test without it. You are intentionally avoiding testing in a way that will pick up bugs.

Also, with Docker it's now actually feasible to automatically test against a real database at a reasonable speed. A Postgres container spins up in a couple of seconds, a SQL Server one in a little over four.



That has nothing to do with docker, really. I run postgres standalone on my laptop and it starts in < 1 second.


I guess they meant so your tests can start with a blank or reproducible state.

But you can of course achieve the same by running a script before your tests start. There are also some frameworks for doing this sort of thing too, such as Fixie for .NET


I've done "write a script to reset the database" before, although not for Pgsql. The effort and potential snags involved make it nowhere near as trivial as docker rm && docker run.

There are also other scenarios that become really simple with disposable DB instances. Want to test a remote data transfer feature? Just spin up two databases.


Drop-create scripts! One of my first epiphanies in the testing world.


Create only scripts can also be great in the right context.

Namely a context like travis-ci where you get a new clean environment each time.

Personally, I've develop few libraries/web UIs that relies on external software like a DNS server or an ldap directory.

And for those, I've a quick and dirty shell script that deploys bind/OpenLDAP.

It's far easier, faster and more accurate than mocking.

For example, what comes to my mind is the testing I do for all the SSL/TLS modes I support (SSL, StartTLS, certificate check disable or not, etc) in my ldap web application.

Travis also has available services in their build envs (stuff like redis, mongodb, mysql, cassandra...).


I do this with rsync to restore a snapshot of the database data folder.


Sure, but I presume that doesn't include installation time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: