How did I miss this?
Wednesday, April 16, 2008
Wednesday, March 26, 2008
Quote of the day
Good judgement is the result of experience ... Experience is the result of bad judgement.—
Wednesday, January 30, 2008
Playing with the .NET FCL symbols and source code
I’m playing with the debug symbols for the .NET framework and came across some interesting things in code.
Dropping back to memory manipulation for performance from the String class
// Returns the entire string as an array of characters.
unsafe public char[] ToCharArray() {
//
int length = Length;
char[] chars = new char[length];
if (length > 0)
{
fixed (char* src = &this.m_firstChar)
fixed (char* dest = chars)
wstrcpyPtrAligned(dest, src, length);
}
return chars;
}
AMD Specific code!
#if AMD64
// for AMD64 bit platform we unroll by 12 and
// check 3 qword at a time. This is less code
// than the 32 bit case and is shorter
// pathlength
while (length >= 12)
{
if (*(long*)a != *(long*)b) break;
if (*(long*)(a+4) != *(long*)(b+4)) break;
if (*(long*)(a+8) != *(long*)(b+8)) break;
a += 12; b += 12; length -= 12;
}
#else
while (length >= 10)
{
if (*(int*)a != *(int*)b) break;
if (*(int*)(a+2) != *(int*)(b+2)) break;
if (*(int*)(a+4) != *(int*)(b+4)) break;
if (*(int*)(a+6) != *(int*)(b+6)) break;
if (*(int*)(a+8) != *(int*)(b+8)) break;
a += 10; b += 10; length -= 10;
}
#endif
Friday, December 14, 2007
DBPro for unit testing - PITA
1. Roll back of initial test state is difficult
There is no easy way to begin a transaction in the setup and rollback in the tear down without modifying the generated code to use transaction scope. The setup/tear down methods cannot be used because they run on a separate connection than the test is executed. This is important for security testing but not all that applicable to the work that we perform. I don’t think it’s reasonable for the tear down methods to have to reverse all the work of the test setup methods. Database rollback is the appropriate approach. Therefore, we have reverted to not using anything but the body of the test.
2. Inability to share T-SQL code to setup common state across tests
This is forcing us write T-SQL setup code that is duplicated across multiple tests or we resort to putting all the testing for a given state into single test. These tests are then testing a single unit (stored proc, trigger, view, etc.) but are testing multiple conditions. If the first condition fails, all subsequent tests will not execute. Also, using state that was modified by a previous test can be very problematic and creates interdependencies between tests.
3. Test designer for specifying test conditions is difficult
The point/click interface for editing many test conditions becomes laborious for large numbers of result sets and columns. Managing inline T-SQL with RAISERROR statements is easier and allows a script to be reviewed without the designer surface.
4. T-SQL test editing designer is not friendly for debugging your test
Most people find that using SQL Management Studio to write/debug your unit tests is easier. In order to use SMS you must copy-paste your code in and out of the DBPro test designer. This process is error prone and laborious.
5. DBPro is slow at executing tests
6. Data Generation Plans are not useful
I may be wrong but I don’t find the Data Plan Generation facility very useful for most unit tests. I see how it would be useful for performance or load testing but these types of tests are much higher level.
7. Integrating the DBPro tests into the build process is not easy
This has not been attempted yet but it does not appear on the surface to be easy.