How to setup and cleanup my Database before and after the UI tests run

1.2k views Asked by At

I am trying to automate ui tests on my Silverlight App. I need to setup and clear my Oracle Database when I run the tests.

I've created a script: "setup.sql" where I define the the query that I want to execute. I add this file on the Deployment Tab on Localsettings configurations.

setup.sql

  CREATE TABLE HSDEV.TESTE_MARIA1
  (
    Id_test int,
    LastName varchar(255),
    FirstName varchar(255)
  )

Then, I created a .bat file and I add this file on Deployment tab com Localsettings configurations and I choose this path on Setup and Cleanup Scripts.

setup.bat

sqlcmd -S COMPUTERNAME -i setup.sql

Both files are in solution folder.

Then, I create a simple web test and I ran it. The test pass but the table wasn't create on my Database.

What am I doing wrong? Am I missing something?

1

There are 1 answers

6
PVitt On BEST ANSWER

You shouldn't setup your database for coded ui tests. Instead you should mock your database. The user interface is the system under test (SUT), not your database. You have to isolate your SUT as far as possible. And this is usually done with mock frameworks.