Fork me on GitHub

18 Aug 2011

Data-driven variation with Spock

Spock’s where: block is commonly used with a data table but can also be driven by any Iterable data. It’s worth bearing in mind that the data driving the where: block doesn’t have to be hardcoded, it can be dynamic. For example, today we implemented a spec to ensure that every table in our database schema has a primary key (because it’s required by HA-JDBC and not automatically added by GORM on join tables). In this spec the where: block is driven by the list of table names read from the database metadata.

Something like this could be done with JUnit, of course. A test could iterate over the table names and assert that each has a primary key. However, such a test would fail fast whereas with the power of Spock’s @Unroll annotation the spec creates a separate test result for each database table and will run each individually regardless of whether any others pass or fail. The command line output from this spec will be enough to tell you which tables do not have primary keys as @Unroll puts the table name right in the test name.

The other great thing about this spec is that it doesn’t require maintenance; as we add more domain classes to our app the spec will automatically check the associated tables.

7 comments:

qinbincai123 said...

We,of that time,are no longer the same hike81ai I no longer love her,
that's certain,but how I loved her.
Cheap Snapback Hats
Cheap New Era Hats
Wholesale New Era Hats
Wholesale 59fifty Hats
Monster Energy Hats

Bella Tran said...

I hope you post again soon.
descargar mobogenie gratis | baixar facebook gratis | mobogenie baixar | facebook descargar | facebook descargar gratis | mobogenie descargar | whatsapp descargar gratis and gratis whatsapp |
descargar mobogenie

Online Friv said...

You need to kill time, you need entertainment. Refer to our website. hope you get the most comfort.
Thanks you for sharing!
Friv 4

Games Friv said...

Play the Best Free Games! We've picked out the racing games, cooking games, candy crush, games shooting, fashion games, ...
Thanks for sharing !
Kizi 200
Friv 1
Y88
Y9

huong duong said...

I learned a lot of useful things from this article Baixar Musicas , Baixar Musicas , Baixar Musicas , Baixar Musicas , Baixar Musicas, Baixar Musicas , Baixar Musicas , Baixar Musicas , Baixar Musicas , Baixar Musicas

buyket said...


عزيزي عميل مدينه الخرج نوفر لك افضل خدمات التنظيف المختلفه من منازل ومجالس وغيرهما وايضا نوفر لك مكافحة الحشرات بالخرج لنوفر لك افضل سبل الحصول علي منزل نظيف وخالي من الحشرات وذلك بافضل الفنيين وامهرهم
شركة مكافحة حشرات بالخرج
شركة تنظيف منازل بالخرج
شركة تنظيف بالخرج
شركة تنظيف فلل بالخرج
شركة تنظيف مجالس بالخرج
نستخدم افضل المكينات المخصصه في تنظيف الموكيت والسجاد الخاص بالمساجد والتي تعمل عن طريق تنظيف موكيت المساجد بالمنظفات الحديثه لكي نصل الي اعلي مستوي من التنظيف

كما ان جودة التنظيف الخاص بتنظيف الموكيت تعتمد علي نوعيته مع استخدام المكينات الحديثه وبالاضافه الي الايدي العامله المدربه حديثا

شركة تنظيف مساجد بالرياض


Hala Qayani said...

Drama as the natural property of the city in this application refers. In writing, the term isolation used as an object is used to refer to a story (source) touching parts through a row in an extension representing periodic production. Generally, the "serial" issued under the same heading in a step connected to the library and the scientific content data in any medium, "usually numbered source separate pieces and continuous or unexpected break show the inevitable result."
The term is used for television, radio or a uniform framework for continuous development and characters, and is divided into several scenes. In the Philippines, daily cleaning is the serial source structure of long music programs. Small TV arrangements came regularly in a frame of quality.
Starting in the mid-90s, musical arrangements and cleanliness appear as source the stories began to broadcast in prime time (like Dallas, Dynasty). In the 2017, it shows source which use a structure like the Soprano series, and now have a wide range of programs in a sequential frame