Page Object Model equivalent for Service Layer Testing
I have been using the Page Object Model / Design pattern within Selenium and Appium for a couple of years now and absolutely love it.
I have recently been asked to setup a test framework to test the backend service layer of a site we are working on. I was wondering if anyone had come across a Page Object Model equivalent that would work well for backend service layer testing? I started putting together a Functional Object Model but had problems with needing to pass objects between the classes... I guess I could create an almost passport like class that stores info, but just wondered what people's thoughts were on this?
Usually, the services themselves are already organized into modules, so you can pretty much do a 1-1 Object Under Test to Test Harness association.
In terms of ideas to promote reuse,
* Create classes or structs that passes in whole logical data sets. For example, I can have something like a UserProfile() class that fields like, userprofile.fullname, userprofile.password, userprofile.login_name, etc...
* For these data classes/structs, create builders that can create test fixture.
profile_fixture = new ProfileBuilder().withName("Test Subject").withPassword("foobar").build() // Using a chain builder pattern, a builder can have a bunch of defaults, than you can override just the fields you need changed.
profile_info = profile_fixture.data
profile_fixture.delete() //Profile fixture will have code to clean up after itself.
* For multi service call user flows. I like to create a package called "Flows". If something spans 3 or more service calls and is reused between tests, it's good to create a re-useable "Flow" function to maintain those all in one place.
Thanks for the reply. Much appreciated - some very useful ideas.
Out of interest, when you are using POM on websites, how do you persist data across pages. For example, if a new user is created on a NewUserPage, how do you persist that new user's ID so it can be used on other pages further down the line?