This is a migrated thread and some comments may be shown as answers.

Coded step help!

4 Answers 123 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sammy78
Top achievements
Rank 2
Sammy78 asked on 15 Jul 2010, 08:19 PM
Hi,
we're currently in the process of aquireing licences for the developer edition and the QA edition.

I'm currently trying to make a coded step test that would be a function that would take parameters (DB, field, expected value, and query) so that the test would query the DB, compare the value with the expected value and if it's the same, the test passes.

Could you help me out please, I'm a bit lost (and we're the first team to use WebUI in our company)

Thank you very much
Sam

4 Answers, 1 is accepted

Sort by
0
Missing User
answered on 15 Jul 2010, 09:23 PM
Hello Sam,

Thanks for the post and your trial of WebUI Test Studio.  You many not need to write code in order to access a data base in that you can try using WebUI's data driven feature.

From the description of the scenario you are trying to test, you can try using a verification test step, as described in the Quick Start under 'Adding Quick Verification Steps' and 'Creating Advanced Test Verifications', then data drive that step, as described in 'Creating a Data Driven Test'.

We strongly recommend this approach as it would make test maintenance much easier. However, if you're still interested in writing custom SQL queries, we cannot help with the queries, but you can still do all of that I mentioned above, then customize the verification step as described under 'Customizing Your Test Using C# or VB.NET Code'.

Please let us know if you have any questions on this.

All the best,
Nelson Sin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sammy78
Top achievements
Rank 2
answered on 16 Jul 2010, 01:03 PM
Hello Nelson,
Thanks for the quick reply.

I checked out your suggestions, and they would be appropriate if my test was related to the interface itself. I'll explain: after having done all the tests with the interface (or at least some tests), our application changes many values in different tables of the DB, and the analyst wants to be able to have tests that are easily customizable (my fonction) to create tests to go make sure that the values have been correctly modified.

I hope that I've explained my problem a little better and that you'll be able to help me. I'm not looking for help with the query itself, simply with the way to make a coded step test (which would include my fonction) and how to tell the test when a test passes or fails.

Thanks a lot
Sam
0
Sammy78
Top achievements
Rank 2
answered on 16 Jul 2010, 01:21 PM
Here is the function that I want to call in my test:

VB:
Private Function Verification_BD(ByVal bd As String, ByVal champ As String, ByVal champWhere As String, ByVal id As String) As Boolean
    Dim myConnection As OleDbConnection
    Dim myCommand As OleDbCommand
    Dim dr As OleDbDataReader
    Dim result As String = ""
    myConnection = New OleDbConnection('{connection string info})
      
    Try
        myConnection.Open()
        'opening the connection
        myCommand = New OleDbCommand("select " + champ + " from " + bd + " where " + bd + "." + champWhere + "='" + id + "'", myConnection)
          
        dr = myCommand.ExecuteReader
        While dr.Read
            result = dr(0).ToString
        End While
        myConnection.Close()
        If result = "N" Then
            Return True
        Else
            Return False
        End If
    Catch e As Exception
    End Try
End Function
0
Sammy78
Top achievements
Rank 2
answered on 16 Jul 2010, 02:44 PM
I've found my solution.
I simply added my function to the test, and then puiit an assert.isTrue on the returning result. Thanks for taking the time to help me out.

Sincerely yours,
Sam
Tags
General Discussions
Asked by
Sammy78
Top achievements
Rank 2
Answers by
Missing User
Sammy78
Top achievements
Rank 2
Share this question
or