1

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?

apaderno
  • 28,547
  • 16
  • 75
  • 90
user1051434
  • 167
  • 1
  • 5
  • 17

1 Answers1

1

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.

PVitt
  • 11,500
  • 5
  • 51
  • 85
  • yes, I know that I could use mock objects to do that. I've searched about mock frameworks but I didn't find anythinf useful, can you please hel me? – user1051434 Nov 17 '11 at 10:48
  • Wikipedia has a nice article about Mocking: https://en.wikipedia.org/wiki/Mock_object There is RhinoMocks, http://www.ayende.com/projects/rhino-mocks/downloads.aspx there is NMock http://www.nmock.org/ there is Moq https://code.google.com/p/moq/ – PVitt Nov 17 '11 at 11:01
  • Thank you. My problem is that I cannot decide alone what I'll do. If my team leader decides to test a real database I'll have to do it. I'll have a clean database just for tests so it will not be a problem. – user1051434 Nov 17 '11 at 11:24
  • Can you please give me more details about my first post? How can I use the setup and cleanup scripts to alter my database on my codedUItests? – user1051434 Nov 17 '11 at 11:25
  • 1
    I would argue that this is not the correct answer, and that there are scenarios that require full stack testing for integration testing, regression testing and so on, so this answer is somewhat misleading. – Nikola Markezic Oct 07 '15 at 07:52
  • 1
    @NikolaMarkezic You are right, but the OP asked specifically for UI testing. – PVitt Oct 08 '15 at 19:54