Business Oriented Testing: FIT vs. DSL

time to read 1 min | 189 words

Jeremy Miller is talking about getting disillusioned about FIT, and I have to agree. FIT is a good idea, but the implementation leaves a lot to be desired. For myself, I am very interested in the ability to express the requirements in a way that is clear, concise and can hopefully make sense to a business user.

Instead of going with the FIT route, I think that I would go with a DSL for testing the domain. For instance, let us say that I want to test scheduling work for employees.

Something like this:

emp = Employee("Smith", Qualifications: [ Medic, Doctor ] )
requirement = Requirement(For: Medic)
assert requirement.MatchedBy(emp)

Now, this looks a lot a unit test, right, but the advantage here is with the bigger scenarios, this mainly simplify ObjectMother scenarios, but it can make the test a lot easier to figure out.

doc = Employee("Smith", Qualifcations: [Medic, Doctor] )
driver = Employee("Joe", Qualifications: [Driver, Medic] )

cannot_work_together doc, driver, "Had a fight"

shift = Shift("Morning")
task = shift.Tasks.Add("Ambulance")
task.AddRequirement( Requirements.Doctor )
task.AddRequirement( Requirements.Driver )

shift.Add( doc )

assert_would_fail shift.Add( driver )

assert_false shift.CanBeSatisfiedBy( driver )