mauriciotogneri / green-coffee

Green Coffee
MIT License
231 stars 21 forks source link

GreenCoffeeTest has only constructors taking scenarios #1

Closed getsadzeg closed 7 years ago

getsadzeg commented 8 years ago

When I run a test it says:

junit.framework.AssertionFailedError: Class has no public constructor TestCase(String name) or TestCase()

So it seems GreenCoffeeTest has only constructors taking scenarios.

What can I do @mauriciotogneri ?

StackOverflow Link

mauriciotogneri commented 8 years ago

Hi @getsadzeg, sorry for the late response. Due to the fact that tests in GreenCoffee require:

@RunWith(Parameterized.class)

The static method annotated with @Parameters must return a list of something. In the examples in the documentation I simply return a list of scenarios, that's why the constructor must take a single Scenario as a parameter.

However, you can create a class that encapsulates the scenario and other objects that you may need to pass to the constructor. So you will get something like this:

public MembersFeatureTest(TestParameters testParameters) {
    super(testParameters.scenario);
}

@Parameters
public static Iterable<TestParameters> parameters() throws IOException {
    return // create the list of TestParameters
}

I added an answer in the stackoverflow question explaining this: http://stackoverflow.com/a/39627382/2087433

Let me know if you encounter any issues.