agourlay/cornichon

Harden BodyElementCollectorMacro

agourlay opened this issue · 0 comments

The BodyElementCollectorMacro is a critical component of the library.

It is the foundation of the entire user facing DSL.

implicit final def featureBuilder(f: FeatureBuilder): BodyElementCollector[ScenarioDef, FeatureDef] =
  BodyElementCollector[ScenarioDef, FeatureDef](scenarios => FeatureDef(f.name, scenarios, f.ignored))

implicit final def scenarioBuilder(s: ScenarioBuilder): BodyElementCollector[Step, ScenarioDef] =
  BodyElementCollector[Step, ScenarioDef](steps => ScenarioDef(s.name, steps, s.ignored, focused = s.focus))

There are currently two main issues with it.

Lack of unit tests

The existing tests just validate whether a snippet of Scala code using the DSL compiles or not.

This is not enough to provide a safety net when changing the macro, the content of a feature could be altered while still compiling.

We need an extensive battery of tests that verify that a given DSL input creates a specific FeatureDef object with specific ScenarioDefs inside.

Poor performance

On large projects with large features, compilation time tends to increase a lot due to the execution of the macro.

The macro has never been optimized seriously due to the lack of tests assuring the correctness of the improvements (see previous point).

There must be some low hanging fruits to make compilation time more reasonable.