Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Testing Comments in Production Code

Author  Topic 

ramoneguru
Yak Posting Veteran

69 Posts

Posted - 2007-03-21 : 16:49:28
Is it sloppy to put in some commented values to test code? Like this:

<SQL Statements>

/*
Tests:
INSERT INTO Temp
SELECT DISTINCT Id FROM Person

exec spGetRankDate '1/1/2000', '1/1/2007'

etc...

*/

Its always seemed to be helpful, but I was wondering if it might be a bad habit for production code? I normally keep all my test comments like that on my dev scripts, but was wondering whether or not its an issue if they make their way into the production files. Does it even matter?

What do the people of SQLTeam do?
--Nick

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-03-21 : 16:54:07
It is not a bad habit for production code.

I almost always have an example call to the stored procedure at the top in the comment header block.


Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-03-21 : 17:44:25
+1 for Test Code in the Source.

We have a "commented out" block, at the end of our Sprocs, which contains all the regression tests and general "snippets" for testing.

They are thus in the source code file, but also(in extremis) in the database and can be retrieved using: sp_helptext 'MySproc'

Kristen
Go to Top of Page

ramoneguru
Yak Posting Veteran

69 Posts

Posted - 2007-03-21 : 19:24:49
Awesome.
--Nick
Go to Top of Page
   

- Advertisement -