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

api to modify created hierarchy of descriptors would help IDE integration #1077

Open
akozlova opened this issue Jan 28, 2015 · 3 comments
Open

Comments

@akozlova
Copy link

In IntelliJ IDEA test's tree is build upon descriptors hierarchy. So if one would like to change it, he need to change the descriptors hierarchy. In some simple cases it's done by the IDE. E.g. if user ask to run one test method for a test class, descriptor for class with exactly one child is created but the IDE hides the top level node with the following reflection abuse

 private static Description getFilteredDescription(Request request, Description description) throws NoSuchFieldException, IllegalAccessException {
    Field field;
    try {
      field = FilterRequest.class.getDeclaredField("fFilter");
    }
    catch (NoSuchFieldException e) {
      field = FilterRequest.class.getDeclaredField("filter");
    }
    field.setAccessible(true);
    final Filter filter = (Filter)field.get(request);
    final String filterDescription = filter.describe();
    if (filterDescription != null) {
      boolean isMethodFilter = filterDescription.startsWith("Method");
      if (isMethodFilter && canCompress(description)) return (Description)description.getChildren().get(0);   
    }
    return description;
  }
@kcooney
Copy link
Member

kcooney commented Jan 28, 2015

Which Description is passed into this method and how does that description relate to the passed-in request?

@akozlova
Copy link
Author

request is created via org.junit.runner.Request#classWithoutSuiteMethod filtered by Description.createTestDescription(clazz, methodName). Top level description corresponds to the test class and the child description corresponds to the selected test name.

@Fuud
Copy link

Fuud commented Apr 7, 2015

How should it affects runners hierarchy? Or it should affect only Descriptions?

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