Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting using different json files in Class/SubClass #242

Open
patown opened this issue Nov 2, 2020 · 3 comments
Open

Supporting using different json files in Class/SubClass #242

patown opened this issue Nov 2, 2020 · 3 comments

Comments

@patown
Copy link
Contributor

patown commented Nov 2, 2020

A TestBase class is commonly useful to setup shared test context . Hope Hoverfly could support this scenario below,

Public class TestBase() {
@ClassRule
public static HoverflyRule logonRule = HoverflyRule.inCaptureOrSimulationMode("logon.json");
}

public class TestA extends TestBase {
@ClassRule
public static HoverflyRule TestARule = HoverflyRule.inCaptureOrSimulationMode("TestA.json");
//
}

public class TestB extends TestBase {
@ClassRule
public static HoverflyRule TestBRule = HoverflyRule.inCaptureOrSimulationMode("TestB.json");
//
}

@tommysitu
Copy link
Member

Hi @patown, that's a very useful scenario which I haven't thought of. I guess you want logonRule to be invoked on all the subclasses, and then every subclass has a specific simulation too.

The current hoverfly-java doesn't support it, but it's doable, as hoverfly already has a REST API for combining simulations (https://docs.hoverfly.io/en/latest/pages/reference/api/api.html#post-api-v2-simulation), that leaves us to make some tweaks in the library to support it.

It's not going to have multiple hoverfly rules though, one hoverfly per test is recommended to avoid conflicts in proxy config. So something like this:

Public class TestBase() {
@ClassRule
public static HoverflyRule baseRule = HoverflyRule.inCaptureOrSimulationMode("logon.json");
}

public class TestA extends TestBase {

// Setup
baseRule.captureOrSimulate("TestA.json", ImportMode.APPEND);

}

public class TestB extends TestBase {

// Setup
baseRule.captureOrSimulate("TestB.json", ImportMode.APPEND);
}

@patown
Copy link
Contributor Author

patown commented Nov 10, 2020 via email

@patown
Copy link
Contributor Author

patown commented Feb 8, 2021

How can we do this in Junit5 ?
baseRule.captureOrSimulate("TestA.json", ImportMode.APPEND);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants