Setup/Cleanup Oracle databse before/after run Ui test

8 posts, 0 answers
  1. Maria Isabel
    Maria Isabel avatar
    5 posts
    Member since:
    Nov 2011

    Posted 21 Nov 2011 Link to this post

    Hello,

    I am trying to aumate UI tests to mu Silverlight App.

    I'll need to setup my Oracle database before I run some tests. And cleanup my database after I run the test.
    I have a C# sample code that does this operation but the compilation is not correct.

    I created a script step and I copy this code there as: 

    [CodedStep(@"New Coded Step")]
            public void connectDB_CodedStep()
            {
                string connectionString = "User Id=myusername;Password=mypassword;Data Source=(DESCRIPTION=" +
                                            "(ADDRESS=(PROTOCOL=myprotocol)(HOST=myhost)(PORT=myport))" +
                                            "(CONNECT_DATA=(SID=mysid)));";
                
                using (OracleConnection connection = new OracleConnection())
                {
                    connection.ConnectionString = connectionString;
                    connection.Open();
                    Console.WriteLine("State: {0}", connection.State);
                    Console.WriteLine("ConnectionString: {0}",
                                      connection.ConnectionString);


                    OracleCommand command = connection.CreateCommand();
                    OracleCommand command1 = connection.CreateCommand();
                    string sql = "CREATE TABLE TABLE_NAME (First_Name char(50))";
                    command.CommandText = sql;
                    


                    OracleDataReader reader = (command).ExecuteReader(); 
                    while (reader.Read())
                    {
                        string myField = (string)reader["MYFIELD"];
                        Console.WriteLine(myField);
                    }
                }
            } 

    I know that this code is correct because I've already tried on a Visual Studio project.
    My doubt is where I need to copy this sample to create my new table and delete it after the test.

    Can you help me?

    Thank you.

    Best regards,
    Marie
  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 21 Nov 2011 Link to this post

    Hi Maria Isabel,

    You will probably want to place that code within a OnAfterTestCompleted() or OnBeforeTestStarted() method, outside of the actual coded step method. See here for a tutorial.

    What compilation error do you get? I suspect you need to add a reference to the Oracle dll to your Test Studio project.

    Best wishes,
    Anthony
    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. Matthew
    Matthew avatar
    10 posts
    Member since:
    Oct 2015

    Posted 01 Jun Link to this post

    The link to the tutorial is broken.  Can you direct me to where this tutorial now resides?  Also, is there any concept of beforeTest or afterTest without using code?  I don't mind using the coded steps, I'm just curious if we can set steps or tests as steps to run before/ after tests for setup/ cleanup.  Thanks!
  4. Aaron
    Aaron avatar
    31 posts
    Member since:
    May 2016

    Posted 02 Jun in reply to Matthew Link to this post

    Hey Matthew,

    I think this is the link you're looking for here. Also, I don't believe there is any sort of GUI way of dealing with before/after tests...I'm almost positive using code is the only way to override them.

  5. Matthew
    Matthew avatar
    10 posts
    Member since:
    Oct 2015

    Posted 02 Jun in reply to Aaron Link to this post

    Thank you Aaron, thats great!  Any idea if there is a concept of before/after suite?  I'm trying to figure out if I can do something like log in once at the beginning of a group of tests so I don't need to log on for each individual test.
  6. Aaron
    Aaron avatar
    31 posts
    Member since:
    May 2016

    Posted 02 Jun in reply to Matthew Link to this post

    Are you testing stuff in a browser? You could use a test list, add your tests to it, and then set the "RecycleBrowser" property to true if that is the case (see attached image).

    I'm not sure if there is a similar solution for WPF's.
  7. Matthew
    Matthew avatar
    10 posts
    Member since:
    Oct 2015

    Posted 02 Jun in reply to Aaron Link to this post

    I am using a browser to test.  Thank you I will try your suggestion.
  8. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    251 posts

    Posted 06 Jun Link to this post

    Hello Matthew,

    Thank you for choosing Telerik Test Studio. 

    @Aaron: Thank you for interfering in this thread and providing useful tips. 

    The feature that Aaron shared last is quite like what you have described as a requirement. So please give it a try and let me know in case you need further assistance. 

    Here is the article for OnAfterTestCompleted() or OnBeforeTestStarted() methods if you still need anything similar.

    Please let me know if you need further assistance. 

    Regards,

    Elena Tsvetkova
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top