ASP.net, Unit tests and Cruise Control experiences anyone?
-
Hello all, I've been looking for a while now for something that I can use to do unit testing on my asp.net UI projects (as opposed to the class libraries, for which I use NUnit). Specifically, I want to test the UI, eg, if I click this button, that text appears. So far, I seem to have found 2 things that may fit the bill: Selenium[^] (specifically the RC version) and WebAii[^] which is still in beta and looks fairly new. One problem with both of them seems to be that they launch a browser to run the tests. I think this means that I wouldn't be able to use them on my CruiseControl.net server as it runs without being logged in. :( Does anyone have any experience with either of these two products (or have any other suggestions) before I commit to one or the other? PS: - this isn't a programming question - it's a "test" / "your experiences" question :) Cheers,
ChrisB ChrisDoesDev[^]
-
Hello all, I've been looking for a while now for something that I can use to do unit testing on my asp.net UI projects (as opposed to the class libraries, for which I use NUnit). Specifically, I want to test the UI, eg, if I click this button, that text appears. So far, I seem to have found 2 things that may fit the bill: Selenium[^] (specifically the RC version) and WebAii[^] which is still in beta and looks fairly new. One problem with both of them seems to be that they launch a browser to run the tests. I think this means that I wouldn't be able to use them on my CruiseControl.net server as it runs without being logged in. :( Does anyone have any experience with either of these two products (or have any other suggestions) before I commit to one or the other? PS: - this isn't a programming question - it's a "test" / "your experiences" question :) Cheers,
ChrisB ChrisDoesDev[^]
Chris Buckett wrote:
One problem with both of them seems to be that they launch a browser to run the tests. I think this means that I wouldn't be able to use them on my CruiseControl.net server as it runs without being logged in.
You can drive the tests using selenium RC without having a logged in user. You can convert the selenium tests to nunit/mbunit tests using the selenium IDE.
[TestFixture] public class NewTest { private ISelenium selenium; private StringBuilder verificationErrors; [SetUp] public void SetupTest() { selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:4444"); selenium.Start(); verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheNewTest() { selenium.Open("/search?client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&channel=s&hl=en&q=resharper+beta&meta=&btnG=Google+Search"); selenium.Click("link=Download - JetBrains.net"); selenium.WaitForPageToLoad("30000"); selenium.Click("link=ReSharper 3.0 Changes"); selenium.WaitForPageToLoad("30000"); try { Assert.AreEqual("Introduce field", selenium.GetText("//li[4]/ul/li[4]")); } catch (AssertionException e) { verificationErrors.Append(e.Message); } } }
You can then run those happily on your build server. It would be nice to be able to use a stub nunit test to pull in the html table tests and generate the code at test time so you can also use the HTML tests without maintaining the manual conversion process, but I don't think anybody has implemented that yet. -
Chris Buckett wrote:
One problem with both of them seems to be that they launch a browser to run the tests. I think this means that I wouldn't be able to use them on my CruiseControl.net server as it runs without being logged in.
You can drive the tests using selenium RC without having a logged in user. You can convert the selenium tests to nunit/mbunit tests using the selenium IDE.
[TestFixture] public class NewTest { private ISelenium selenium; private StringBuilder verificationErrors; [SetUp] public void SetupTest() { selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost:4444"); selenium.Start(); verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheNewTest() { selenium.Open("/search?client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&channel=s&hl=en&q=resharper+beta&meta=&btnG=Google+Search"); selenium.Click("link=Download - JetBrains.net"); selenium.WaitForPageToLoad("30000"); selenium.Click("link=ReSharper 3.0 Changes"); selenium.WaitForPageToLoad("30000"); try { Assert.AreEqual("Introduce field", selenium.GetText("//li[4]/ul/li[4]")); } catch (AssertionException e) { verificationErrors.Append(e.Message); } } }
You can then run those happily on your build server. It would be nice to be able to use a stub nunit test to pull in the html table tests and generate the code at test time so you can also use the HTML tests without maintaining the manual conversion process, but I don't think anybody has implemented that yet.Cheers for the code snippet (although it's made the post look like a programming question!) Thanks for clearing that up - I'd read somewhere previously that the CruiseControl server had to be logged in.
ChrisB ChrisDoesDev[^]
-
Hello all, I've been looking for a while now for something that I can use to do unit testing on my asp.net UI projects (as opposed to the class libraries, for which I use NUnit). Specifically, I want to test the UI, eg, if I click this button, that text appears. So far, I seem to have found 2 things that may fit the bill: Selenium[^] (specifically the RC version) and WebAii[^] which is still in beta and looks fairly new. One problem with both of them seems to be that they launch a browser to run the tests. I think this means that I wouldn't be able to use them on my CruiseControl.net server as it runs without being logged in. :( Does anyone have any experience with either of these two products (or have any other suggestions) before I commit to one or the other? PS: - this isn't a programming question - it's a "test" / "your experiences" question :) Cheers,
ChrisB ChrisDoesDev[^]
We run Selenium on a build server and it has no problems. We've used the Java RC and Selenium on Rails.
regards, Paul Watson Ireland & South Africa
Shog9 wrote:
And with that, Paul closed his browser, sipped his herbal tea, fixed the flower in his hair, and smiled brightly at the multitude of cute, furry animals flocking around the grassy hillside where he sat coding Ruby on his Mac...
-
We run Selenium on a build server and it has no problems. We've used the Java RC and Selenium on Rails.
regards, Paul Watson Ireland & South Africa
Shog9 wrote:
And with that, Paul closed his browser, sipped his herbal tea, fixed the flower in his hair, and smiled brightly at the multitude of cute, furry animals flocking around the grassy hillside where he sat coding Ruby on his Mac...
Cool, Cheers for that. Selenuim looks like the way to go.
ChrisB ChrisDoesDev[^]
-
Cool, Cheers for that. Selenuim looks like the way to go.
ChrisB ChrisDoesDev[^]
Hi - You can also run WebAii in non-interactive mode. (I think that is what you are asking for?). WebAii is also integrating the Plasma server http://www.codeplex.com/plasma in next couple of weeks so if you are doing ASP.NET testing you will be able to do testing with no need for a browser or any webserver. All running inproc. Hope that helps.
-
Hi - You can also run WebAii in non-interactive mode. (I think that is what you are asking for?). WebAii is also integrating the Plasma server http://www.codeplex.com/plasma in next couple of weeks so if you are doing ASP.NET testing you will be able to do testing with no need for a browser or any webserver. All running inproc. Hope that helps.
Sounds good, perhaps I'll take another look at that.
ChrisB ChrisDoesDev[^]