SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Easy and Repeatable Testing of DB Code (Stored Procs, etc.) with DbFit


Easy and Repeatable Testing of DB Code (Stored Procs, etc.) with DbFit

Author
Message
Chris Falter
Chris Falter
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 8
Most of the Fit fixtures you can run from Fitnesse can also be run by FitRunner.exe from the command line. You can run a DoFixture, ActionFixture, ColumnFixture, RowFixture, etc. via FitRunner.exe. Is it possible to use FitRunner.exe to execute DbFit fixtures?
eharper
eharper
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 549
Is there any way to increase the command timeout in DBFit?

I would like to test some complex data warehouse ETL stored procedures, but I've hit a problem as several run for longer than the default timeout (30 seconds), even on test data.
Alexander Kuznetsov
Alexander Kuznetsov
SSC-Addicted
SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)

Group: General Forum Members
Points: 401 Visits: 824
Solomon Rutzky (11/13/2008)
Alexander Kuznetsov (11/13/2008)
Solomon Rutzky (11/13/2008)
Alexander Kuznetsov (11/13/2008)
How would you test the following cases:
- my stored procedure modifies two tables and returns a result set;


3) To test any result set, use either the "Query" or "Ordered Query" operations. It does not matter what else the Stored Procedure does.


IMO yes it does - how do you verify that the modifications are exactly as you expect?



Ok, sorry, I misunderstood the intent of that question. To test both the modifications made in the Stored Procedure and the result set returned, you would do the following all within the same page:

a) use the "Query" operation calling EXEC on the Stored Procedure to test the result set
b) use the "Query" operation again calling SELECT * FROM Table1 to test that change
c) use the "Query" operation again calling SELECT * FROM Table2 to test that change


Solomon, in my experience the "SELECT * FROM Table1 to test that change" approach is very inefficient. Come to think of it, next month or next year you will have to add some more test data for some other requirement, and that will break your "test that change" piece. It is much better to test exactly the change - the difference between the original and the modified states.
gojko adzic
gojko adzic
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 2

Most of the Fit fixtures you can run from Fitnesse can also be run by FitRunner.exe from the command line. You can run a DoFixture, ActionFixture, ColumnFixture, RowFixture, etc. via FitRunner.exe. Is it possible to use FitRunner.exe to execute DbFit fixtures?


in .NET, yes. FolderRunner and other .NET runners are 100% compatible with the normal fitnesse runner. In Java, the fit runner is not 100% compatible with fitnesse runners, so you can't do it from the command line.
gojko adzic
gojko adzic
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 2
Is there any way to increase the command timeout in DBFit?

if you can do that in the connection string, then yes (just set it in the connect operation). Otherwise, not at the moment.
gojko adzic
gojko adzic
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 2


Solomon, in my experience the "SELECT * FROM Table1 to test that change" approach is very inefficient. Come to think of it, next month or next year you will have to add some more test data for some other requirement, and that will break your "test that change" piece. It is much better to test exactly the change - the difference between the original and the modified states.


for large tables, if the table has an autoincremented id, you can do something like:

|query|select max(id) as top from table|
|top|
|>>currentmax|

// do your test here

|query|select * from table where id>@currentmax|
|col1|col2|col3|
Alexander Kuznetsov
Alexander Kuznetsov
SSC-Addicted
SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)SSC-Addicted (401 reputation)

Group: General Forum Members
Points: 401 Visits: 824
gojko adzic (11/21/2008)


Solomon, in my experience the "SELECT * FROM Table1 to test that change" approach is very inefficient. Come to think of it, next month or next year you will have to add some more test data for some other requirement, and that will break your "test that change" piece. It is much better to test exactly the change - the difference between the original and the modified states.


for large tables, if the table has an autoincremented id, you can do something like:

|query|select max(id) as top from table|
|top|
|>>currentmax|

// do your test here

|query|select * from table where id>@currentmax|
|col1|col2|col3|


works only for inserts and only if the table has identity.
Ian Gregson
Ian Gregson
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 43
I would like to be able to create a test around the metadata returned from a stored procedure.

My scenario :- I will receive Column A, Column B & Column C from a stored procedure.

If another developer changes the sproc to return another column, Column D, I want my test to fail.

'Inspect Query' does return the metadata but I can't figure out a way of sticking that into a test.

Any idea how I can acheive this?
Solomon Rutzky
Solomon Rutzky
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1687 Visits: 2965
ian.gregson (2/10/2011)
I would like to be able to create a test around the metadata returned from a stored procedure.

My scenario :- I will receive Column A, Column B & Column C from a stored procedure.

If another developer changes the sproc to return another column, Column D, I want my test to fail.


Hi Ian. The only way I can get this to work is to cause a SQL Server exception when the test runs as opposed to a handled DbFit error. I hope this ok as it does kinda work.

1) Use the |Execute| method to create a temp table to hold the expected columns
2) Use a second |Execute| to INSERT into the temp table from an EXEC to the Stored Proc

Example:

!|Execute| CREATE TABLE #ResultSetTest (first VARCHAR(50), second VARCHAR(50), third INT) |
!|Execute| INSERT INTO #ResultSetTest (first, second, third) EXEC Test.dbo.TestProc |

If the result set of the Proc does not match the temp table, then you will get an exception stating:

System.Data.SqlClient.SqlException: Column name or number of supplied values does not match table definition.


Take care,
Solomon...

SQL# - http://www.SQLsharp.com/
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)

Group: General Forum Members
Points: 84943 Visits: 41071
eharper (11/21/2008)
Is there any way to increase the command timeout in DBFit?

I would like to test some complex data warehouse ETL stored procedures, but I've hit a problem as several run for longer than the default timeout (30 seconds), even on test data.


I'm not trying to be a "smart guy" here... I'm concerned about the code being tested. Wouldn't the fact that something takes longer than 30 seconds "even on test data" be the first indication of a possible major performance problem which needs to fixed prior to going to production?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search