The Artima Developer Community
Sponsored Link

Java Community News
Go Ahead. Break the Build

5 replies on 1 page. Most recent reply: Jan 25, 2007 12:42 PM by Robert Evans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Go Ahead. Break the Build Posted: Jan 23, 2007 3:13 PM
Reply to this message Reply
Summary
Elliotte Rusty Harold recently published a blog that looks at the issues surrounding what to do when a unit tests fails, thereby breaking the build. Should everything stop until that test passes again?
Advertisement

In Go Ahead. Break the Build, Elliotte Rusty Harold describes eXtreme Programming's philosophy on breaking the build, and points out where his philosophy differs:

There’s a philosophy in extreme programing circles that one should never break the build. As soon as the build is broken, everything stops until it can be fixed again. Some teams even hand out "dunce caps" to a programmer who breaks the build.

If by "build" you simply mean the compile-link-package cycle, then I tend to agree. Breaking the build is pretty serious. One of the advantages of extreme programming is that the increments of work are so small that you don’t get very far before discovering you’ve broken the build, so it’s relatively easy to fix. Integration is almost automatic rather than a painful, months long process.

... [But] This is where I part company from the most extreme of the extremists: if building includes passing all unit tests, then it is often acceptable and even desirable to break the build.

Harold lists several reasons a failed test may be introduced but not fixed immediately, including:

  • The person who writes the failing test may not be qualified to fix the bug.
  • The programmer may need to spend some time thinking about how to fix the bug before fixing it.
  • The bug may be an easy fix, but the programmer has to leave to pick his daughter up from soccer practice.
  • Sometimes bugs are beyond the programmer's control, because they reflect bugs in the environment.

Harold concludes that:

For whatever reason, not every bug can be fixed immediately. It’s still better to commit the failing unit test so it doesn’t get forgotten in the future, even if that 'breaks' the build.

...All too often projects are in denial about their bugs. Rather than accept clear evidence of a bug, they do anything they can to deny it. Refusing to allow the build to break, and then defining a test failure as build breakage, is just one example of this pathology. Recognizing, identifying, and reproducing a bug with a well-defined unit test is a valuable contribution. It should be accepted gladly, not met with hostility and an insistence that the reporter immediately provide a patch.

TestNG and JUnit 4 each have an Ignore attribute, which can be used to temporarily turn off execution of a failing test. Of course, a synonym for this attribute could be Forget or OutOfSiteOutOfMind, because without a glaring red bar it may be easy to put off going back to fix an Ignore'd failing test.

How do you handle such situations? Do you try and fix all failing tests immediately? If you allow a test to fail for a while sometimes, what techniques do you use to make sure someone remembers to go back and fix it later? Would it be helpful if the Ignore attribute took an optional date after which the test will start failing again?


Daniel Yokomizo

Posts: 22
Nickname: dyokomiso
Registered: Sep, 2002

Re: Go Ahead. Break the Build Posted: Jan 23, 2007 8:13 PM
Reply to this message Reply
Every decent team uses a version control system and every half-decent VCS support branches. There's no reason to not have a stable branch that always passes all unit tests. If a developer need to commit his changes without ensuring that the unit tests pass, he should commit to a personal/feature branch. In the last project I was on we had a main branch that was available for acceptance testing and one branch per feature. Inside your branch do whatever you want, but in the main branch all unit tests must pass.

There's no excuse for breaking the build that will be tested or shipped. Ever.

Alex Blewitt

Posts: 44
Nickname: alblue
Registered: Apr, 2003

Re: Go Ahead. Break the Build Posted: Jan 23, 2007 8:53 PM
Reply to this message Reply
In my experience, people who focus on tests breaking the build haven't worked on large complex systems or have such a trivial set of tests that they trivially pass all the time.

In the real world, a build system is supposed to generate deployable code. There are other things that it can do (generate documentation, pretty reports, run tests) but it's naive to assume that build=compile+test.

When you have code that needs to be deployed to remote systems in order to test -- for example, deploying stored prodedures into a database, uploading into an application server, or refreshing a QA database with known-good content -- then things can go wrong at that level. And just because there's some failure in an obscure piece of library code doesn't mean that the entire system is useless.

Yet the anal "I'm not even going to consider running a build until all tests pass" would prevent any kind of QA test like this. Indeed, sometimes there's just runtime errors at the system test level because of borked configuration, rather than code, or because a machine is down.

The idea might be fine for trivial unit tests, but it fails to scale up.

The logical extension of this anal approach is "I'm not going to let the build continue if there are any bugs in the system". After all, when you discover a bug, you write a test for it, right? And every time someone files a new bug, a new test should be written, right? Therefore the build should fail whilst there are bugs in the system. And that's not a sensible proposition.

The right way of building large systems is to separate the concerns of 'compile/package/deploy' and 'test'. Yes, having all tests pass is a good goal to aim for. But that's not practical all the time -- if, for example, Eclipse followed this we-are-stopping-everything-because-of-a-test-failure then it would be decidedly *less* agile than it is at the moment. You only have to look at the nightlies to see that tests do fail on a nightly basis, and that they consider the build 'failed' as a whole if test pass -- but they still generate and supply the deployable outputs. That's necessary, because if I'm writing (say) the JDT code, and someone else is (say) writing the Platform code, then I still need to be able to compile and run my JDT code against the current Platform, even if it has got known bugs or test failures.

Maven's approach of not even considering any further modules in the presence of a test failure tells you *nothing* about what it didn't get around to. Yes, there may be a domino effect whereby one test causes a raft of other test failures. However, in most cases, that won't be the case -- and just because someone else has a test failure shoulnd't mean you don't get to see the results of *your* test.

The other naive thing that is built into this assumption is that the build (and its tests) are quick, and can be re-run again. As the system grows larger, this becomes less and less true. It's not uncommon to have builds which take several hours to complete for really large systems; fail-on-build in these scenarios really doesn't work.

And let's face it -- the whole point of 'agility' is to do things that work, and learn to amend/adapt the process. It's not a prescribed you-must-do-this-or-you're-not-agile approach; it's about building workable software. Anyone who says "you must do this or you're not agile" has completely missed the point of agile development techniques -- the process is supposed to *adapt*, not be fixed in stone.

Fortunately, as systems grow, and people get more experienced, they find that this doesn't work all the time and so adapt their processes. Those that haven't been working on such systems for a while, tend to mandate "this is the way it must be done" without appreciating the downsides. The point is this: you're either agile, and adapt; or you don't.

Alex.

Matt Doar

Posts: 9
Nickname: mdoar
Registered: Feb, 2004

Re: Go Ahead. Break the Build Posted: Jan 24, 2007 9:45 AM
Reply to this message Reply
You've got two knobs to tweak:

1. Percentage of tests executed
2. Percentage of tests passed

You can always turn down the first knob until all the executed tests pass. That way, you get the useful bit of information that tests are now failing, and don't grow used to it.
The setting of the first knob tells you how the testing your large system is doing.

~Matt
http://www.pobox.com/~doar

Geoffrey Wiseman

Posts: 51
Nickname: diathesis
Registered: Aug, 2003

Re: Go Ahead. Break the Build Posted: Jan 25, 2007 7:16 AM
Reply to this message Reply
Seems as if rather than an @Ignore tag, you'd want a @Broken tag that indicates that the test should be run, but you expect it to break. Those tests could be itemized separately, are easy to search for, etc.

e.g.

Test Passed (425 test cases, 0 failures, 0 errors, 12 known broken tests)

Robert Evans

Posts: 11
Nickname: bobevans
Registered: Jun, 2003

Re: Go Ahead. Break the Build Posted: Jan 25, 2007 12:42 PM
Reply to this message Reply
If you know of a test case that needs to be part of the system ultimately, you can write it, and mark it @ignore, you also have a script as part of the automated build that lets you know what you are currently ignoring.

If it is a bug that hasn't been fixed yet, mark it @bug, or something similar, then have a script that reports those on every build as well, and if you have those, maybe mark the build yellow so that people remember there are contingencies.

The problem of broken builds is that it may slow other developers down if they check out a build that is actually broken in a way that they depend on. Then they have to take the time to roll back to a previous version, or add a fix themselves, or wait for a fix. Nothing worse than doing an update on what looks like a green build, when you are trying to integrate something, and then getting hosed and having to back out.

Bob Evans
http://www.junitfactory.com/
Send code, get tests. Free.

Flat View: This topic has 5 replies on 1 page
Topic: Scott Raymond on What's New in Prototype 1.5 Previous Topic   Next Topic Topic: Guidelines for Portlet Writers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use