The primary mechanism in Siesta for code sharing seems to be inheritance. So, initially, I had all my tests inherit from a gigantic base class. This file got too big and unmanageable pretty quickly and mixes the code from several different application modules that we have into a single file.
We have roughly 10 modules, but for the sake of this discussion, let's talk about 3 and call the modules "Inventory", "Staffing", and "Contracts"
I could subclass the base class for each application module - resulting in an Inventory subclass, a Staffing subclass, and a Contracts subclass. The problem is that we have end to end tests that need to hit many different modules. I want to call logic for many different modules from a single test, and multiple inheritance isn't supported (probably not desirable either!).
After browsing the forum I stumbled upon a mention of Joose Roles and they seem to fit the bill. The solution I'm pursuing, and I've successfully created a proof of concept, is to:
1) Keep shared logic in BaseTestClass.js
2) Separate the the logic for each application module into unique Joose Roles. So, I've got role_inventory.js,
role_staffing.js
role_contracts.js
3) Create a test class called endToEndTest.js, which subclasses the main base class and consumes every role. This ends up looking something like
Class('e2eTest', {
isa: baseTestClass,
does: [role_inventory,role_staffing, role_contracts],
methods: {
}
})
Does this make sense as one approach?
Thanks!
-Joe