concordion / cubano

A packaged framework for implementing web and API test suites. Builds on Concordion to bring your software delivery team together around living documentation.
http://concordion.org/cubano/framework
Apache License 2.0
15 stars 2 forks source link

[Feature] Should have a mechanism to not trigger browser when using CubanoTemplateFixture #136

Open hungdao-testing opened 3 years ago

hungdao-testing commented 3 years ago

My Fixture file is a mix of action needed browser interaction and api services. My idea of writing this file along with markdown file is

But when calling the fixture file, the background section triggers browser as well, and causes error. So I would like to ask/clarify is there any existing feature to invoke the browser manually ? , or, any ways to handle SPEC_SCOPE without invoking browser instance while using CubanoTemplateFixture ?

package com.rwa.specs.bankaccount.feature;

import com.rwa.pages.HomePage;
import com.rwa.services.BankAccountService;
import com.rwa.workflow.WorkFlow;
import org.concordion.api.*;
import org.concordion.cubano.driver.http.HttpEasyReader;
import org.concordion.cubano.template.framework.CubanoTemplateFixture;

import java.io.IOException;

@FullOGNL
public class OnBoardingFixture extends CubanoTemplateFixture {

    private WorkFlow workFlow;
    private HomePage homePage;

    @ConcordionScoped(Scope.SPECIFICATION)
    private final ScopedObjectHolder<BankAccountService> userDataSpecScope = new ScopedObjectHolder<BankAccountService>() {

        private BankAccountService bankAccountService;

        public void deleteBankAccountService() {
            bankAccountService = null;
        }

        @Override
        public BankAccountService create() {
            bankAccountService = new BankAccountService();
            return bankAccountService;
        }

        @Override
        protected void destroy(BankAccountService bankAccountService) {
            deleteBankAccountService();
        }

    };

    @BeforeExample
    public void setUp() {
        this.workFlow = new WorkFlow(this);
        this.homePage = new HomePage(this);
    }

    public MultiValueResult setUpOnBoardingData(String fullName) throws IOException {
        HttpEasyReader resp = userDataSpecScope.get().createDefaultUserAccountFromFullName(fullName);
        return new MultiValueResult()
                .with("username", resp.getJsonReader().jsonPath("user.username").getAsString())
                .with("password", "s3cret");
    }

    public boolean triggerOnBoardingProcessForUser(String username, String password) throws IOException {
        this.homePage = this.workFlow.loginWorkFlow(username, password);
        this.homePage.getOnBoardingProcessComponent().waitForOnBoardingDialogLoaded();
        return true;
    }

    public MultiValueResult processOnBoardingFlow(String bankName, String routingNumber, String accountNumber) {
        this.getBrowser().getDriver().navigate().refresh();
        return this.homePage
                .getOnBoardingProcessComponent()
                .waitForOnBoardingDialogLoaded()
                .processOnBoardingWithBankingInfo(bankName, routingNumber, accountNumber);
    }

}

=== Markdown file ===

# On-Boarding

As a newly created user, I want the system to walk me through the On-boarding process so that
I could link a bank profile to my user account.

### Rules: OnBoarding process behavior
- The on-boarding process is triggered to the newly created users. 
  It's triggered once user logs into the application, and would be stopped if user finished setting up banking account.

* This rule is dependent on:
  - [Create newly user](SignUp.md#create_new_user)

### [Background](-):

Given [Dave Lopp](- "#fullName"), a [newly created user](- "#data=setUpOnBoardingData(#fullName)"), was on the Login page

##### [Scenario:](- "trigger on-boarding process") On-boarding process is triggered for newly created users once they log in

<div>
<p concordion:execute="#result=triggerOnBoardingProcessForUser(#data.username, #data.password)">

When he logs into the application with valid credentials

Then the on-boarding process is triggered [properly](- "c:assert-true=#result")

</p>

</div>

#### [Scenario:](- "on-boarding for users") User could pass the on-boarding process with valid banking information

Given he [was On-boarding process](- "triggerOnBoardingProcessForUser(#data.username, #data.password)")

<div>

<p concordion:execute="#process=processOnBoardingFlow(#bankName,#routingNumber,#accountNumber)">

When he provides valid banking information

|Bank Name|Routing Number|Account Number|
|---|---|---|
|<span concordion:set="#bankName">American Bank</span>|<span concordion:set="#routingNumber">031302997</span>|<span concordion:set="#accountNumber">000123456789</span>|

</p>

</div>

Then he could finish the process [successfully](- "c:assert-true=#process.result")