OzFramework / oz

Oz is a behavioral web-ui testing framework developed to reduce test maintenance by using a predictive model rather than a scriptive model when writing tests.
Apache License 2.0
23 stars 7 forks source link

[Feature Evaluation] Compose expected values from the ancestor chain #142

Open Castone22 opened 5 years ago

Castone22 commented 5 years ago

Note: Adds dependency on deep_merge (or we'd have to write a deep merge algorithm ourselves)

Currently there's a bit of a gap where if we have a static text element defined on a BasePage, we have to add it to all inheriting page's yaml files explicitly.

My proposal would be to create a pseudo-inheritance model for the each page's expected values in the inheritance chain. Say we have a hypothetical set of pages as follows

class BasePage < CorePage
end

class Google
  class BasePage < ::BasePage
  end
end

class Google
  class SearchPage < Google::BasePage
  end
end

class Google
  class ResultsPage < Google::BasePage
  end
end

and a directory like so

pages
|\ base_page.rb
|\ google
| |\ base_page.rb
| |\ base_page.yml
| |\ search_page.rb
| |\ search_page.yml
| |\ results_page.rb
| |\ results_page.yml

ResultsPage's inheritance tree would look like

[Google::ResultsPage, Google::BasePage, BasePage, CorePage] 
# and a bunch of random internal ruby junk we'd want to throw out.

The idea here would be that we could define a common static text element in yaml file associated to Google::BasePage, and all child pages (in this case, both results and search) would be expected to contain that static text.

This would increase the maintainability of the content files for each page quite a bit. We would want to crawl the inheritance tree from the top down however so that you could override a given element on a given page (say the search page should show some different text). For bonus points we'd want to ensure that if a yaml file was not defined for a given ancestor page, that the test would continue, as perhaps there is nothing that requires a yaml file to validate on say the base base_page.

greenarrowdb commented 5 years ago

Let's talk about this one on Thursday, there is already a paradigm to handle inherited data in the framework and I'm betting you just haven't seen it yet.