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

Add mocking framework? #7489

Closed
cfontes opened this issue Aug 28, 2014 · 2 comments
Closed

Add mocking framework? #7489

cfontes opened this issue Aug 28, 2014 · 2 comments

Comments

@cfontes
Copy link
Contributor

cfontes commented Aug 28, 2014

Hi,

I am new, and maybe it's just my lack of knowledge.

But wouldn't it be easier to create unit tests with a mocking framework like easymock or mockito.

I am trying to test this parse function, for #7408.

public class FieldValueFactorFunctionParser implements ScoreFunctionParser {
    public static String[] NAMES = { "field_value_factor", "fieldValueFactor" };

    @Override
    public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser) throws IOException, QueryParsingException {

But to do that I need to create a valid QueryParseContext and also a XContentParser. The mock would allow me to focus on the method logic instead of spending time trying to figure out how to get those 2 objects, which I don't care very much about at this point in time (maybe after in the dev I will. But not right now at the start of my wanna be task).

@s1monw
Copy link
Contributor

s1monw commented Nov 7, 2014

We discussed this and came to the conclusion that this is mainly addressed with ElasticsearchSingleNodeTest.java in the test framework. The majority of us are in favor of not adding a mock framework for several reasons mainly related to the mess they tend to create. I am closing this as won't fix

@s1monw s1monw closed this as completed Nov 7, 2014
@s1monw s1monw removed the discuss label Nov 7, 2014
@cfontes
Copy link
Contributor Author

cfontes commented Nov 7, 2014

Thanks for the answer!

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

No branches or pull requests

3 participants