Friday, 1 June 2007

Get random test data into Clipboard


Then we know how to get random data from SQL Server. Would be nice to build a public web page around this where testers easily can get test data for immidiate pasting into the AUT.

Something like this maybe:

1. Specify data to get and from which test environment
2. Click on a button and display the test data and put automaticly in clipboard
3. Paste into the AUT

Create a web form and include


Sub GetTestData
'Set test environment and test data
strTestEnvironment = formname.TestEnvironment.Value'Form reference not used in this example
intTestDataIndex = formname.RandomTestData.SelectedIndex

If intTestDataIndex = 0 Then
strSQL = "SELECT top 1 testdata1 FROM table where testdatatype1 is not NULL ORDER BY NEWID()"
ElseIf intTestDataIndex = 1 Then
strSQL = "SELECT top 1 testdata2 FROM table where testdatatype2 is not NULL ORDER BY NEWID()"
End If
'****** Initialization ******

'Set test environment parameters
strDataBase = "DRIVER=SQL Server; DATABASE=[databasename];APP=[testtool];SERVER=[servername];Description=Testconnection"
'****** Data base call ******
Dim objDB

Set objDB = CreateObject("ADODB.Connection")
Set objRecordSet = objDB.Execute(strSQL)
Dim strResult
If objRecordSet.BOF = True And objRecordSet.EOF = True Then
strTestData = ""
strResult = objRecordSet.GetString
strTestData = Left((Trim(strResult)),Len(Trim(strResult))-1)'Format data
End If
Set objDB = Nothing
formname.TestData.Value = strTestData
End Sub

and finally


function copytestdata(input) {

Start the sequence by using the tag

INPUT TYPE="button" NAME="cmdGetTestData" VALUE="GetTestData" onclick="copytestdata(formname.TestData)"


No comments: