Testers can learn a great deal from the software craftsmanship movement. This talk, given with Matt Barcomb at CAST 2013, shows some great examples of things testers can learn from developers--and what devs can learn from testers.
Sense lights up Points to code or tests which will likely cause you pain later http://en.wikipedia.org/wiki/Code_smell First used in Fowler’s classic Refactoring book Automated tests are code!
to non-automated testing: Multiple test scenarios conflated in one test case Overly complex charters with too many concerns Test desires that are too ambiguous
var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); IWebDriver browser = new FirefoxDriver(exe, profile); WebDriverWait w = new WebDriverWait(browser,TimeSpan.FromSeconds(10)); browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx"); //browser.Navigate().GoToUrl("http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/ CascadingDropDown.aspx"); w.Until(ExpectedConditions.ElementExists(By.XPath("id('ctl00_SampleContent_DropDownList1')/ option[text()='Acura']"))); var sl =browser.FindElement(By.Id("ctl00_SampleContent_DropDownList1")); var l = new SelectElement(sl); l.SelectByText("Acura"); w.Until(ExpectedConditions.ElementExists(By.XPath("id('ctl00_SampleContent_DropDownList2')/ option[text()='Integra']"))); sl = browser.FindElement(By.Id("ctl00_SampleContent_DropDownList2")); l = new SelectElement(sl); l.SelectByText("Integra"); w.Until(ExpectedConditions.ElementExists(By.XPath("id('ctl00_SampleContent_DropDownList3')/option[text()='Sea Green']"))); sl = browser.FindElement(By.Id("ctl00_SampleContent_DropDownList3")); l = new SelectElement(sl); l.SelectByText("Sea Green"); w.Until(ExpectedConditions.ElementExists(By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']"))); browser.Quit(); } BEFORE
var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); IWebDriver browser = new FirefoxDriver(exe, profile); WebDriverWait wait = new WebDriverWait(browser,TimeSpan.FromSeconds(10)); browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx"); wait.Until( ExpectedConditions.ElementExists( By.XPath("id('ctl00_SampleContent_DropDownList1')/option[text()='Acura']"))); var selectionList = browser.FindElement( By.Id("ctl00_SampleContent_DropDownList1")); var optionsList = new SelectElement(selectionList); optionsList.SelectByText("Acura"); wait.Until( ExpectedConditions.ElementExists( By.XPath("id('ctl00_SampleContent_DropDownList2')/option[text()='Integra']"))); selectionList = browser.FindElement( By.Id("ctl00_SampleContent_DropDownList2")); optionsList = new SelectElement(selectionList); optionsList.SelectByText("Integra"); wait.Until( ExpectedConditions.ElementExists( By.XPath("id('ctl00_SampleContent_DropDownList3')/option[text()='Sea Green']"))); … // CLOSING ITEMS ELIDED AFTER Line breaks, FTW Whitespace! Group common things together Lose Comments
var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); browser = new FirefoxDriver(exe, profile); wait = new WebDriverWait(browser,TimeSpan.FromSeconds(10)); browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx"); select_menu_item(1, "Acura"); select_menu_item(2, "Integra"); select_menu_item(3, "Sea Green"); wait.Until( ExpectedConditions.ElementExists( By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']"))); browser.Quit(); } AFTER
var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); browser = new FirefoxDriver(exe, profile); wait = new WebDriverWait(browser, TimeSpan.FromSeconds(10)); browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx"); } [TestFixtureTearDown] public void run_once_after_everything_else() { browser.Quit(); } [Test] public void move_setup_out() { select_menu_item(1, "Acura"); select_menu_item(2, "Integra"); select_menu_item(3, "Sea Green"); wait.Until( ExpectedConditions.ElementExists( By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']"))); } AFTER
"Sea Green"); wait.Until( ExpectedConditions.ElementExists( By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']"))); } BEFORE
forget stuff like “App fails when user enters 18,446,744,073,709,551,614 Ctrl-C characters in 68 concurrent browser windows simultaneously in 38 instances of Chrome, 42 FF 21.5, and IE 4.2 on a leap day at 11:59:58PM after pouring a cup of Guatemala Huehuetenango Finca Regalita roasted at full city+ over the application server. I unplugged the database server in the middle of the commit transaction too. Also there’s a french fry in the biz tier server’s disk array.”