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

Setup/Cleanup Oracle databse before/after run Ui test

7 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maria Isabel
Top achievements
Rank 1
Maria Isabel asked on 21 Nov 2011, 11:50 AM
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

7 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 21 Nov 2011, 05:50 PM
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
0
Matthew
Top achievements
Rank 1
answered on 01 Jun 2016, 09:34 PM
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!
0
Aaron
Top achievements
Rank 1
answered on 02 Jun 2016, 02:30 PM

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.

0
Matthew
Top achievements
Rank 1
answered on 02 Jun 2016, 02:49 PM
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.
0
Aaron
Top achievements
Rank 1
answered on 02 Jun 2016, 02:55 PM
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.
0
Matthew
Top achievements
Rank 1
answered on 02 Jun 2016, 03:28 PM
I am using a browser to test.  Thank you I will try your suggestion.
0
Elena
Telerik team
answered on 06 Jun 2016, 11:48 AM

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!
Tags
General Discussions
Asked by
Maria Isabel
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Matthew
Top achievements
Rank 1
Aaron
Top achievements
Rank 1
Elena
Telerik team
Share this question
or