tag:blogger.com,1999:blog-6040130426871585154.post8775738051342517909..comments2023-04-01T16:47:05.870+02:00Comments on Feelings Erased: Moving to NUnit from MsTest - experience reportGrzegorz Gałęzowskihttp://www.blogger.com/profile/07005911345134430356noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6040130426871585154.post-38632821208044222532016-06-13T00:13:12.958+02:002016-06-13T00:13:12.958+02:00Kam fet, I think you can always send me a private ...Kam fet, I think you can always send me a private message via google plus. <br /><br />The only thing I see in your tests that I find suspicious is that web driver is created through inline field initialization. In MsTest, this would cause a new driver created for each test. In NUnit, this will only create a single web driver for the entire test suite. This may be the reason why the second test in the suite doesn't run as you expected.<br /><br />My advise would be: try moving the creation of web driver to [SetUp] method, before "driver.Navigate().GoToUrl" call.Grzegorz Gałęzowskihttps://www.blogger.com/profile/07005911345134430356noreply@blogger.comtag:blogger.com,1999:blog-6040130426871585154.post-13878353688112403992016-06-09T18:06:05.802+02:002016-06-09T18:06:05.802+02:00Hi, Gregoz,
I was going to send you a direct msg ...Hi, Gregoz,<br /><br />I was going to send you a direct msg but can't see a way to do it. Below is a sample of my tests. <br /><br />using System.Threading;<br />using Microsoft.VisualStudio.TestTools.UnitTesting;<br />using OpenQA.Selenium;<br />using OpenQA.Selenium.Firefox;<br /><br />namespace SmokeTests.SIT<br />{<br /> [TestClass]<br /> public class SIT2ContactUs<br /> {<br /> IWebDriver driver = new FirefoxDriver();<br /><br /> [TestMethod]<br /> public void VerifyEmailValMsgContactUsSIT2()<br /> {<br /> var emailMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[1]"));<br /> Assert.AreEqual("Email is required", emailMessage.Text);<br /> }<br /><br /> [TestMethod]<br /> public void VerifyTitleValMsgContactUsSIT2()<br /> {<br /> var titleMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[2]"));<br /> Assert.AreEqual("Title is required", titleMessage.Text);<br /> }<br /><br /> [TestMethod]<br /> public void VerifyFirstNameValMsgContactUsSIT2()<br /> {<br /> var firstNameMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[3]"));<br /> Assert.AreEqual("First name is required", firstNameMessage.Text);<br /> }<br /><br /> [TestMethod]<br /> public void VerifyLastNameValMsgContactUsSIT2()<br /> {<br /> var lastNameMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[4]"));<br /> Assert.AreEqual("Last name is required", lastNameMessage.Text);<br /> }<br /><br /> [TestMethod]<br /> public void VerifyAppQuestionContactUsSIT2()<br /> {<br /> var appropriateQuestionMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[5]"));<br /> Assert.AreEqual("Please select appropriate question", appropriateQuestionMessage.Text);<br /> }<br /><br /> [TestMethod]<br /> public void QueryValMsgContactUsSIT2()<br /> {<br /> var queryMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[6]"));<br /> Assert.AreEqual("Query is required", queryMessage.Text);<br /> }<br /><br /> [TestMethod]<br /> public void VerifyNoCaptchaErrorCuSIT2()<br /> {<br /><br /> var captchaMessage =<br /> driver.FindElement(By.XPath("/html/body/form/div[4]/div/div/div[2]/div[1]/section/div[1]/div/ul/li[7]"));<br /> Assert.AreEqual("That was quick! To ensure you’re not a spambot, please wait 10 seconds and submit again.",<br /> captchaMessage.Text);<br /> }<br /><br /> [TestInitialize]<br /> public void Setup()<br /> {<br /> driver.Navigate().GoToUrl("http://web2.femi.com/about/contact#.V0bjcoQrLcs");<br /><br /><br /> //Using thread because the system is gettng slower (annoyingly)<br /> Thread.Sleep(5000);<br /> var submit = driver.FindElement(By.ClassName("js-duplicate-button"));<br /> submit.Click();<br /> }<br /><br /> [TestCleanup]<br /> public void TearDown()<br /> {<br /> //close browser<br /> driver.Quit();<br /> }<br /> }<br />}<br />Anonymoushttps://www.blogger.com/profile/13242561921754091196noreply@blogger.comtag:blogger.com,1999:blog-6040130426871585154.post-54755022022759131482016-06-08T14:02:27.177+02:002016-06-08T14:02:27.177+02:00Hi, Kam fet,
I never used Selenium, the only big ...Hi, Kam fet,<br /><br />I never used Selenium, the only big difference I know is that MsTest reinitializes all fieds for each new test, but NUnit doesn't unless you do so explicitly in [SetUp] method. Maybe you have some fields initialized in constructor or inline in a test class?Grzegorz Gałęzowskihttps://www.blogger.com/profile/07005911345134430356noreply@blogger.comtag:blogger.com,1999:blog-6040130426871585154.post-86871736779061738412016-05-25T13:08:22.225+02:002016-05-25T13:08:22.225+02:00Hi,
[TestInitialize] -> [SetUp]
[TestCleanup] ...Hi,<br /> [TestInitialize] -> [SetUp]<br />[TestCleanup] -> [TearDown]<br /><br />The above setup are not working as it does with MSTEST on NUNIT. With MSTest using it in conjunction with Selenium, every time a test runs, it closes the window and moves on to the next test. What I've noticed with Nunit is that it runs the first test, but after that everything elses falls apart. It just fails to re use the SetUp and Teardown. Has anyone faced this issue before?Anonymoushttps://www.blogger.com/profile/13242561921754091196noreply@blogger.comtag:blogger.com,1999:blog-6040130426871585154.post-31412156390156362062016-02-11T14:29:15.116+01:002016-02-11T14:29:15.116+01:00StringAssert.EndsWith(actual, expected) <=> ...<br />StringAssert.EndsWith(actual, expected) <=> StringAssert.EndsWith(expected, actual)Markhttps://www.blogger.com/profile/15434201573652936012noreply@blogger.comtag:blogger.com,1999:blog-6040130426871585154.post-24266920396840149972014-12-10T12:53:16.053+01:002014-12-10T12:53:16.053+01:00Aaron, I am very happy it helped!
If you like, p...Aaron, I am very happy it helped! <br /><br />If you like, please leave a comment on additional things you find out when you're finished migrating. Hopefully others looking at this post and comments will benefit!Grzegorz Gałęzowskihttps://www.blogger.com/profile/07005911345134430356noreply@blogger.comtag:blogger.com,1999:blog-6040130426871585154.post-80509402683636946432014-12-05T11:28:34.133+01:002014-12-05T11:28:34.133+01:00Thanks, this is a really useful guide and saved me...Thanks, this is a really useful guide and saved me a lot of time. I'm going through the same migration at the moment. The generalisations are pretty accurate.Aaronhttps://www.blogger.com/profile/14425150983066184586noreply@blogger.com