Fail the unit tests when the database schema, and entity are changed, but unit tests are not changed
NickName:Nirman Ask DateTime:2019-06-11T20:37:29

Fail the unit tests when the database schema, and entity are changed, but unit tests are not changed

Following is the exact scenario in my application:

  • There are several C# methods in the codebase which are using Entity framework to talk with SQL database.
  • Unit tests are written against all methods, and covers all possible permutation and combinations based on method signature, input requirements, and return values.
  • Unit tests are working fine, and are failing when they should (i.e., cases like some validation is changed or expected return value is changed, but unit tests are not reflected for the same).
  • There are cases, where a developer performs a change in SQL schema, and updates the entity in the C# code. In this case, unit tests are passing which is absolutely fine because its just underlying logic is changed, but not the input, validations, or return value.
  • However, I want some unit tests to be failed when the database schema and entity are changed, but unit tests are not changed. That means, I want developers to fix the unit tests when they change database schema and entity.

Can anyone please suggest how to achieve the same?

Any help on this would be much appreciated.

Thanks

Copyright Notice:Content Author:「Nirman」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/56543925/fail-the-unit-tests-when-the-database-schema-and-entity-are-changed-but-unit-t

More about “Fail the unit tests when the database schema, and entity are changed, but unit tests are not changed” related questions

Fail the unit tests when the database schema, and entity are changed, but unit tests are not changed

Following is the exact scenario in my application: There are several C# methods in the codebase which are using Entity framework to talk with SQL database. Unit tests are written against all metho...

Show Detail

How to make unit test fail when API of mocked module changed

When I write some javascript unit tests for my code, I mocked a methond of a module with sinon, defined what arguments it expected and what it should return. someone changed the argument of that m...

Show Detail

Playframework Database unit tests fail in subprojects

Unit tests in Play subprojects using a database fail due to this Error: javax.persistence.PersistenceException: The default EbeanServer has not been defined? This is normally set via the ebean.

Show Detail

Database Schema Corrupts Unit Tests

Because we are using two different databases for logging tables, we were forced to add a schema to the table annotation, e.g. @Table(name = "TestLog", schema="OTHER_DB.dbo") public class TestLog {...

Show Detail

Have make fail if unit tests fail

I have a makefile for compiling a static library. This makefile has a rule for compiling a unit test suite associated with the static library. Once the test suite is compiled, a python script is in...

Show Detail

Is there a way to start unit tests which related only to changed code?

In my Python project, we have a big number of unit tests (some thousands). Though they are logically distributed between files and classes, I need sometimes a lot of time in order to find ones, which

Show Detail

When multiple unit tests copy the same file, running all unit tests fail

Description I am writing unit tests for a method, which copies a file from a source to a destination. Basically it includes this code: public void MyMethod() { // ... File.Copy(source,

Show Detail

JavaScript unit tests fail during Jenkins build

I have a couple of projects that use Karma to run Jasmine unit tests. We're using npm for package management and Grunt for building our JavaScript projects and executing their unit test tasks. Af...

Show Detail

Unit tests and database

This question about unit tests sparked another thing that's been bothering me. I've gone back and forth on three ways to do unit tests when hitting a database. Create mock objects and plug them in...

Show Detail

Visual Studio unit tests not completing

A new colleague is unit testing using VS pro 2019#'s built-in unit test, as we all do. With one solution (.sln) none of the unit tests complete when run from the Test Explorer, no matter whether Ru...

Show Detail