Questions tagged [unit-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
44
votes
5answers
32k views

Unit testing of stored procedures

I've been considering this for quite a long time now. The basic question is: how to unit test stored procedures? I see that I can set up unit tests relatively easily for functions in the classic ...
8
votes
4answers
13k views

Temporary schema per connection?

I am trying to migrate my unit tests from H2 to Postgresql. Currently, H2 gives me an in-memory schema such that each connection maps to a unique schema, creates the tables, runs the test, and drops ...
7
votes
2answers
585 views

How can I fake inet_client_addr() for unit tests in PostgreSQL?

I have a simple stored procedure whose return value depends on the value of inet_client_addr(). How can I override inet_client_addr() for the purpose of unit tests when testing my stored procedure? ...
5
votes
3answers
999 views

Can PostgreSQL support integration test with some kind of throwaway overlay?

It's a common problem to write integration tests that include a database. If the test changes the database then it could effect other tests or the next run of itself. I know that I could wrap my test ...
5
votes
1answer
430 views

Reinitialize Table Values in SQL SSDT Unit Testing

I am creating SQL Server Unit Tests. We are testing various stored procedures. In Unit testing principles, it is good practice to setup a small database table, populate values, and tear down (...
5
votes
1answer
799 views

Test Driven Design for postgres procedures

I am looking to introduce a test driven design style to writing my stored procedures for a postgresql database implementation. I have seen that pgTap is a popular unit testing tool for postgres and ...
4
votes
1answer
4k views

DROP DATABASE statement cannot be used inside a user transaction

Not really sure if this question belongs here, but I hope someone could help me out. I've made integration tests going all the way down to the database (using mssql localDB). I want each test to run ...
4
votes
3answers
12k views

EXPORT specific columns to INSERT statements

Is there a way to export specific columns and a fixed number of rows from a table to INSERT statements? I am trying to generate these for unit testing based on a large production table so using ...
4
votes
1answer
608 views

Optimizing MySQL 5.6 for unit tests

We have a MySQL instance for unit tests. Our unit tests work very heavily on MySQL. Therefore, we put /var/lib/mysql dir in tmpfs file system because we don't need persistent data in unit tests. Our ...
3
votes
1answer
439 views

What does @RC mean in SSDT SQL Server Unit Testing?

In Sql Server Unit Testing, SSDT, what does @RC stand for? Does it mean Row Count, or Row Column? Team wants to understand, we have been using it for long time, good tool which works, just curious.
3
votes
1answer
522 views

What is the standard de facto unit test framework for Postgres?

I am new to Postgres and as I am about to start writing more and more code with it (script with procedures, etc.) I am wondering what is the "standard de facto" (more used, bigger community, open ...
2
votes
3answers
4k views

How do I unit test queries which are based on dates from now?

I've had a hard time making unit test for most of my queries because they are tied very closely to current dates and data which is added to the database could modify the result of the unit test. For ...
2
votes
1answer
491 views

Sql Server Stored Procs vs Linq with C# and unit testing

I'm going to run into a situation where I am, where the stored proc vs Linq is going to come up. I know I'm asking this in the DBA stackexchange so most of you might say use stored procs, but I'm ...
2
votes
1answer
11k views

Is there any way to clear all tables using Liquibase?

I'm currently using Liquibase for creating test data in my database before each test run. I came across a problem where some of the test cases need special data, while others need the tables to be ...
1
vote
3answers
395 views

What circumstances could a SQL DateTime column hold an invalid date?

I have been asked to write a series of tests within SQL. Many of them are to test if a certain DateTime columns held in the system is a valid date. Given that the all the fields in question are ...
1
vote
1answer
405 views

Write a slow SQLITE query to test timeout

Is it possible to write a 'simple' SQLite query that will take more than 5 seconds to run. I am writing some unit-tests in my application to log slow queries, to that end, I would like a slow query ...
1
vote
1answer
113 views

PgTap, unit test a foreign key is deferrable

I am using PgTap to unit test a Postgres (v9.4) database structure in a continuous migration process. It works great. Here is my question: « Is there a way to control that a foreign key constraint is ...
1
vote
1answer
2k views

How to do jUnit testing by PostgreSQL?

I found some packages like pgTAP but I would like to get community supported tools. I am using PostgreSQL 9.4.3 in Debian 8.1. I have many kinds of tests which I would like to do: INSERT by ...
1
vote
0answers
28 views

Unit Testing ORDS - Oracle Rest Data Services

I've been wanting to develop some unit tests for my ORDS functions as part of my push for better CI/CD - I am running ORDS functions on an Oracle Autonomous Database 19c, and while I'm developing a ...
1
vote
1answer
49 views

Test-Automation: Diff Data in Oracle Database - what are best practices? [closed]

We're re-writing a COBOL application in Java. We want to make sure, the applications behave the same, by validating our unit tests produce the same DB changes. How can we easily diff the data in the ...
-1
votes
1answer
42 views

Automated testing of SQL scripts

I'd like to run some simple tests on SQL scripts in CI to just ensure the scripts are valid SQL (PostgreSQL). While I could run Postgres in Docker or even use an in-memory DB such as Sqlite (it's ...