lisp-unit is a Common Lisp library that supports unit testing
My belief is that unit testing is for everyone and, in fact, I’ll go so far as to say that I believe becoming a test-driven developer is the single best change a programmer can make in their day to day routine.
$5 + 10 CHF = $10 if rate is 2:1
$5 * 2 - $10
Make "amount" private
Dollar side effects?
Money rounding?
equals()
hashCode()
Equal null
Equal object
5 CHF * 2 - 10 CHF
Dollar/Franc duplication
Common equals
Common times
Compare Francs with Dollars
Currency?
$5 + 10 CHF = $10 if rate is 2:1
$5 * 2 - $10
Make "amount" private
Dollar side effects?
Money rounding?
equals()
hashCode()
Equal null
Equal object
5 CHF * 2 - 10 CHF
Dollar/Franc duplication
Common equals
Common times
Compare Francs with Dollars
$5 + 10 CHF = $10 if rate is 2:1
$5 * 2 - $10
Make "amount" private
Dollar side effects?
Money rounding?
equals()
hashCode()
Equal null
Equal object
5 CHF * 2 - 10 CHF
Dollar/Franc duplication
Common equals
Common times
public void testMultiplication {
Dollar five = new Dollar(5);
assertEquals(new Dollar(10), five.times(2));
assertEquals(new Dollar(15), five.times(3));
}
$5 + 10 CHF = $10 if rate is 2:1
$5 * 2 - $10
Make "amount" private
Dollar side effects?
Money rounding?
equals()
hashCode()
Equal null
Equal object
public void testMultiplication {
Dollar five = new Dollar(5);
assertEquals(new Dollar(10), five.times(2));
assertEquals(new Dollar(15), five.times(3));
}
$5 + 10 CHF = $10 if rate is 2:1
$5 * 2 - $10
Make "amount" private
Dollar side effects?
Money rounding?
equals()
hashCode()
public void testEquality() {
assertTrue(new Dollar(5).equals(new Dollar(5)));
}
The goal is clean code that works - Ron Jeffries
So we want to test multiplication and make sure that the "times()" method returns the right amount when passed a multiplier.
public void testMultiplication() {
Dollar five = new Dollar(5);
Dollar product = five.times(2);
assertEquals(10, product.amount);
product = five.times(3);
assertEquals(15, product.amount);
}
RSpec is a behaviour specification framework for Ruby. RSpec was created in
response to Dave Astels’ article _A New Look at Test Driven
Development_ which can be read at: daveastels.com/index.php?p=5
RSpec is intended to provide the features discussed in Dave’s
article.
In this article you will discover how to use how to use NUnit V.2 efficiently with your .Net projects.