Don't be afraid of the big bad stack trace
It's surprising how many people are intimidated by stack traces. A reaction that I regularly see when a stack trace appears on screen is panic!
"Oh my god! Something has gone wrong! There are hundreds of lines of text talking about code I don't recognize and I can't take it all in; what do I do?"
The first thing to do is to relax; stack traces have a lot of information but they are actually really friendly and helpful things. Let's modify our project to produce a stack trace and work through it. We are going to make a small change to the getDriver()
method in DriverFactory
to force it to always return null
by using this code:
public static WebDriver getDriver() { return null; }
This is going to make sure that we never return a driver object, something that we would expect to cause errors. Let's run our tests again, but make sure that Maven displays a stack trace by using the -e
switch:
mvn clean verify -e
This time, you should see a...