Search code examples
javatestingspring-mvcjunitbrowser-testing

Can JUnit be used as an alternative to browser testing in Spring?


I'm building a Spring web app and up until now all of my testing is using a browser.

This involves starting the server, opening a browser window and checking to see if accessing any of the pages causes an error.

This is starting to get repetitive and doesn't seem to be the most efficient way to do this.

Since the Junit jar file is already in my project, could it be used as an alternative to this browser testing and, if so, any tips on how to get started making JUnit simulate the act of opening a browser to access the web app?


Solution

  • Take a look at Selenium. It allows you to script functional tests using JUnit or TestNG and execute them in a browser, automatically.