Coded step help!

5 posts, 0 answers
  1. Sammy78
    Sammy78 avatar
    27 posts
    Member since:
    May 2010

    Posted 15 Jul 2010 Link to this post

    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
  2. Missing user
    Missing user avatar

    Posted 15 Jul 2010 Link to this post

    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
  3. Sammy78
    Sammy78 avatar
    27 posts
    Member since:
    May 2010

    Posted 16 Jul 2010 Link to this post

    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
  4. Sammy78
    Sammy78 avatar
    27 posts
    Member since:
    May 2010

    Posted 16 Jul 2010 Link to this post

    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
  5. Sammy78
    Sammy78 avatar
    27 posts
    Member since:
    May 2010

    Posted 16 Jul 2010 Link to this post

    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
Back to Top