Back when I was in college, learning Software Development involved a lot of processes, while dotting your i’s and crossing your t’s. As a programmer/developer, you had to be meticulous and nit-picky with your code while achieving all of the given requirements. That takes a lot of work. Sometimes you hit the mark perfectly, sometimes you don’t. As my professor once told me, “If every piece of software was perfect, then every developer would be out of a job”. Enter a test engineer. He doesn’t necessarily need to know every piece of code, all he has to do is to test if the code does what its supposed to do.
Black box testing is the rudimentary step of any kind of testing. The name essentially speaks for itself. Imagine you’re looking at a box, and you were told that this box has different objects in it, and you need to identify every single object in the box. Black box testing can be synonymous to sticking your hand (without looking inside) into the box, grabbing an object and identifying it. This kind of method essentially means that you have no access to the raw code itself, and you would have to test the piece of software with only the metrics the developers give you. Now, this seems like a primitive process and people resenting the run-and-gun, shoot from the hip, testing method. In actuality, Black box testing, holds one key importance in the software process: Business value. As a test engineer, you are looking for the user experience, and not the developer experience. Those are two completely different things. A developer can look at a piece of apple and say that its spherical and red, while a user can say, that an apple is just a plain old apple.
This is where Behat excels in identifying the business value of a piece of software. According to its documentation:
“Behat is a tool that makes behavior driven development(BDD) possible. With BDD, you write human-readable stories that describe the behavior of your application. These stories can then be auto-tested against your application.” (http://behat.readthedocs.org/en/v2.5/quick_intro.html)
Behat fits the Black Box Testing mold perfectly, as no code is involved whatsoever in the testing process (mind you, there is some coding involved in setting up your company’s context). What’s great about it is; it combines gherkin, mink and selenium to create a simple, plain english testing platform that someone without any programming or computer science background to test. All one needs is a general understanding of the english language. Lets take a look at an example of how Behat works against a typical test suite.
Looking at a piece of code from Selenium (exported to java):
driver.findElement(By.xpath("//input[@id=\"edit-title\"]")).sendKeys("Testing Title 1"); assertTrue(isElementPresent(By.xpath("//input[@id=\"edit-path-alias\"]")));
For conversation’s sake, that code says that I am looking for an element that has a specific id, type in its field and assert that it is present. Behat takes care of all of that without ever typing a piece of code.
Given I am on “Address” When I type in “Testing title 1” on “Title” field Then I should see the text “Testing title 1”
There are many uses between Black box testing and Behat, and the technology is not limited to these as well. More thorough testing can be found in different forms of testing and different platforms to apply these. But if you’re looking for a reliable way to get the user experience of your software, get the business value of your software, and have essentially everyone contribute to the testing process, Black box testing combined with the Behat platform is definitely the recommended route to go. It’s simple, easy to learn, compact and a great tool to add to your arsenal in developing, whether it be applications or websites.