- #CONNECT TO LOCAL DYNAMODB TS FOR FREE#
- #CONNECT TO LOCAL DYNAMODB TS HOW TO#
- #CONNECT TO LOCAL DYNAMODB TS FULL#
I want to see unit tests on the simple bits, because I know they won't always be simple. I know that not everyone shares this view, but I like to see 100% unit test coverage on the projects I work on. Testing should be a natural part of the development flow, not a big pile of extra work to do at the end of a feature implementation.Ī good test setup is an amazing thing.
Eventually tests break, get skipped or become permanent TODOs.
If it isn't, the ROI on its use will be too low. It's not enough to have the perfect mock. I actually did get this to work, but much like my Mockito tests, it was too much effort. For example, if you want a test to run that involves an S3 bucket, you might think you can just create the bucket as part of a docker-compose up, but there isn't really a hook that localstack gives you to do things like that and so you wind up with race conditions and "flaky" tests. The biggest frustration I had with localstack wasn't just with running an AWS service but it was the effort of putting that service into some state where I could reasonably run a unit test against it. Apparently I'm to assume everything works just like the real AWS, except of course that isn't true and the gaps are for me to figure out. But if you're really going cloud native? It's miserable. If you just need a couple of AWS services, like an S3 bucket, localstack can work out very well. Anyway, that has worked well for me and putting that Dockerized database into a CI pipeline has also produced good results for me.Īs I started to get more into AWS, I reached for something else in that familiar pattern - Docker images that would give me a "good enough" implementation so I could develop offline. I know that some say "mock the database and test the business layer", but that won't catch my app spitting out invalid or nonsensical SQL.
#CONNECT TO LOCAL DYNAMODB TS FULL#
Putting a full database (including tables and data) into a Docker image is actually a fantastic way to go if you are using RDBMS.
#CONNECT TO LOCAL DYNAMODB TS HOW TO#
I did spend a bunch of time figuring out how to use Docker to build out a development environment and run tests against a pre-seeded database. I'm happy to say I never again wrote a "unit test" against a live database after that. As far as I know, that system still exists and still works but I'd be surprised if the unit tests are providing much value. I did manage to write a few decent tests, but they took a long time to write and the return on investment just wasn't there to mock everything. These brittle tests were more trouble than they were worth! In an effort to get some value out of unit testing, I struggled with some of the mocking libraries that were available at the time, such as the ironically-named EasyMock and the diminutive (?) Mockito. Sometimes tests would fail because a row was deleted or added or because time had passed (how dare it!). Whenever the database schema changed, some tests would probably need to be updated, or they'd fail. If the tests couldn't negotiate a connection to that database, they would fail. Several years ago, I worked on a team that wrote "unit tests" in Java that mostly ran against a development copy of a relational database (Oracle, to make matters worse). The most important thing I've learned about testing is that it is a skill that requires some work as well as a smart approach. I believe strongly in automated testing as a practice to keep systems stable and to enable innovation, refactoring and even to automate maintenance updates. The other features I like about Jest are snapshots and test tables, but they will need to be covered another time. One of them is that it ships with a very powerful mocking capability. Some readers may think Jest is a lot like some of the other JavaScript/NodeJS testing frameworks, but it has a few features that I really think set it apart from anything else I've used. I like working with these tools a lot and I like sharing the ways I've found to use them together.
#CONNECT TO LOCAL DYNAMODB TS FOR FREE#
I tried to think of a few chuckles, but then I got to thinking about writing blogposts for free to promote the projects of companies that are worth hundreds of billions of dollars, and maybe the joke is just on me?Īnyway, no need to think on that one too much. This seems like a very punny subject, mocking the world's leading cloud provider.