Questions tagged [unit-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
22 views

How to handle an expected exception in base postgres

I want to be able to write a .sql script that will carry out an action which fails, and the script should only report failure if the action doesn't fail. For example, given initial table: create table ...
  • 226
0 votes
0 answers
62 views

Is there a utPLSQL way to mock procedures, functions, or tables?

In tSQLt, you can isolate dependencies for unit testing using procedures like FakeTable to create a dummy version of whatever your test subject depends on, that contains only data you specify. This is ...
  • 153
0 votes
2 answers
94 views

MariaDB 10.6 InnoDB setttings for unit-tests: maximize performance at the expense of persistence

I have a MariaDB 10.6 the db is used for phpunit tests. The database is dropped and recreated each time I run the unit tests. I would like to maximize the speed of the interactions (read/write) with ...
  • 151
1 vote
1 answer
300 views

truncate table in mysql 8.0 is slower than older version

I have few hundreds of tests which use mysql. I was using Mysql 5.7 (percona) and I changed it to Mysql 8.0 . My problem is that before every test I truncate ALL my tables. This was fine with 5.7 but ...
2 votes
2 answers
806 views

Are SQL unit tests supposed to be so long?

I am writing stored procedures with some non-trivial business logic. I am trying to unit test them, but the actual tests end up being quite long (shorter ones starting at 40-50 LoCs, using commonly 4 ...
0 votes
1 answer
24 views

How to test a function that selects from real tables?

I've got a mega function that everybody is afraid to modify. So each fix adds a dozen of new IF lines. To me it feels that this function screams for proper testing. Instead of the real function I'm ...
  • 121
1 vote
0 answers
238 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 votes
1 answer
244 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 ...
  • 129
1 vote
1 answer
82 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 ...
3 votes
1 answer
1k 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.
user avatar
5 votes
1 answer
583 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 (...
user avatar
1 vote
3 answers
2k 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 ...
7 votes
1 answer
1k 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 ...
1 vote
1 answer
1k 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 ...
3 votes
1 answer
794 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 ...
  • 1,153
5 votes
1 answer
986 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 ...
  • 153
3 votes
1 answer
588 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 ...
5 votes
2 answers
5k 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 ...
  • 185
1 vote
1 answer
165 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 ...
  • 255
1 vote
1 answer
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 ...
2 votes
3 answers
6k 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 ...
  • 123
11 votes
4 answers
18k 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 ...
  • 989
9 votes
2 answers
859 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? ...
  • 539
5 votes
3 answers
1k 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 ...
6 votes
3 answers
17k 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 ...
  • 333
44 votes
5 answers
33k 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 ...
  • 30.1k
2 votes
1 answer
15k 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 ...
  • 123