Domanda

I want to run my test cases in selenium on multiple browsers(FF & IE).since same test case runs twice, I want to clean my databases after running each test cases.(otherwise second test case will fail since already that data has entered)

Is there any method to clean databases after running each test cases? (running a shell script or what ever method)

I have to deal with mysql and mongo db. previously, when I run with single browser, I used a shell script to clean and reinstall initial data to databases.

È stato utile?

Soluzione

Can't you just simply run these scripts before each test run? Running DB cleaning BEFORE tests is better than running it after. Beacause when sth changes in the meantime you still can be sure that when you run your build, the DB must be in default state cause it was just cleaned by your scripts. From maven you can execute bat/shell files http://maven.40175.n5.nabble.com/How-to-execute-a-script-in-maven2-td106785.html

Just use one of the phases like pre-integration-test: Maven and Exec: forking a process?


Personally I would choose a more complex solution with build automation included. Consider using a CI server (Continous Integration). It is responsible for building your app after each code change. You can check out the Jenkins - it's free. Using such tool enables you to have multiple Jobs running. Right there you can then configure one job to build your app and other job to run tests on your app. Before the tests you can then simply run bat/shell scripts in form of pre-steps or even post-steps. The process is of course simplified just to get you the overall view on it. If you want to know more just ask :)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top