Writing Good Unit Tests; Don't Mock Database Connections

Writing Good Unit Tests; Don't Mock Database Connections

There’s no way to test this function without having a database connection available at the time of testing. If a new developer clones the project they will need to set up a database or else tests will fail.

Unit tests are unbelievably important to us as developers because they allow us to demonstrate the correctness of the code we’ve written. More importantly, unit tests allow us to make updates to our code base with the confidence that we haven’t broken anything. In our eagerness to get 100% code coverage, however, we often write tests for logic that perhaps we have no business testing. I’m here to assert that creating mock database abstractions in order to write unit tests is a bad idea almost all of the time.

testing unit test

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Software Testing 101: Regression Tests, Unit Tests, Integration Tests

How do scientists demonstrate that a drug or vaccine is effective? Putting it to the test. It's your only choice. And, if you're reasonable, you'd never use medications that haven't been thoroughly tested. So, why don't you test software as thoroughly as you should?

Unit Testing Is NOT The Same As Integration Testing

Unit Testing Is NOT The Same As Integration Testing. The foundation of software resilience are integration and unit tests. Let's look at the distinctions between the two today, as well as when you would choose one over the other.

Testing Microservices Applications

The shift towards microservices and modular applications makes testing more important and more challenging at the same time. Learn more here.

Unit test vs. Programmer test vs. Integration test

What are Programmer tests? See a clear example of each kind.

Another look into unit testing and integration testing

Another look into unit testing and integration testing. Unit Testing and Integration Testing are the initial and most important stages of testing. Apart from these there are some other phases in testing.