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

Adapt JUnit4 runner according new API #5710

Merged
merged 14 commits into from
Jul 20, 2017
Merged

Adapt JUnit4 runner according new API #5710

merged 14 commits into from
Jul 20, 2017

Conversation

svor
Copy link
Contributor

@svor svor commented Jul 17, 2017

What does this PR do?

Added a base implementation of JUnit4 framework.
What was made:

  • Recognize JUnit4 test framework in a java file;
  • Run only one test method from the opened test class;
  • Run all test methods from the opened test class;
  • Annalize a test class and build the tree of tests before running;
  • Debug mod for running tests.

The simple demo:
https://youtu.be/fEM9dLDzRmo

What issues does this PR fix or reference?

#5473

Changelog

  • Run/Debug JUnit4 tests by using JUnit4 API
  • Build a tree of tests before running
  • Can run one test method or all tests from the test class

Release Notes

In this version we have been implementing JUnit4 API for running tests. We added default interfaces and mecanism which will allow to bring better test capabilities inside of Eclipse Che. We have also reworked the JUnit runner in order to use features:

Run one test method:
one_test

Run all tests from the test class:
test_class

Debug test:
debug

@svor svor added kind/enhancement A feature request - must adhere to the feature request template. team/ide labels Jul 17, 2017
@svor svor added this to the 5.15.0 milestone Jul 17, 2017
@svor svor self-assigned this Jul 17, 2017
@svor svor changed the title Che 5473 Adopt JUnit4 runner according new API Jul 17, 2017
@codenvy-ci
Copy link

@svor svor changed the title Adopt JUnit4 runner according new API Adapt JUnit4 runner according new API Jul 18, 2017
@codenvy-ci
Copy link

parameters.setJavaExecutable(JAVA_EXECUTABLE);
parameters.setMainClassName(MAIN_CLASS_NAME);

List<String> classPath = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several testing frameworks or test runners (such as arquillian, etc ...) assume that the current working directory should be the root directory of the project.
See this issue as an example.
So it seems that the working directory should be explicitly set to the root directory of the project being tested.
This would also be consistent with the way tests are run inside maven afaik.
This has already been done for the TestNG part ( see this discussion and this line ).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss to set a value of the working directory. Thank you!

@codenvy-ci
Copy link

@riuvshin riuvshin modified the milestones: 5.15.0, 5.16.0 Jul 18, 2017

private static final Logger LOG = LoggerFactory.getLogger(AbstractJavaTestRunner.class);
protected static final String PROJECTS_ROOT_FOLDER = "/projects";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace hrdcoded "/projects" with
@Named("che.user.workspaces.storage") File projectsRoot ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can. I've replaced

public static void treeNode(PrintStream out, Description description) {
String location = description.getClassName() + "." + description.getMethodName();
out.println(create("suiteTreeNode",
new Pair("name", escape(description.getMethodName())),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some constant here for "name", "location" and etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to constants

/**
* JUnit implementation for the test runner service.
*/
public class TestRunner extends AbstractJavaTestRunner {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to JUnit4TestRunner ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@codenvy-ci
Copy link

public List<TestResultDto> getTestResults(List<String> testResultsPath) {
throw new UnsupportedOperationException();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

import java.util.Set;

/**
* JUnit implementation for the test runner service.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you an author of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am. But we decided (inside our team) don't add an author to the javadoc.

@slemeur
Copy link
Contributor

slemeur commented Jul 19, 2017

@svor 👍 . Few feedbacks:

  • When the tests are executed, there is no status displayed to the user to know the progress. Would it be possible to display progress information ?

  • Could you record few animated gif for the release note? I think we need to split your video between the new capabilities:
    -- Can run one test method or all tests from the test class
    -- Build a tree of tests before running
    -- Debug test

@codenvy-ci
Copy link

Build # 3110 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3110/ to view the results.

@svor
Copy link
Contributor Author

svor commented Jul 19, 2017

@slemeur I've updated the PR, please take a look

# Conflicts:
#	plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-ide/pom.xml
#	plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-ide/pom.xml
@slemeur
Copy link
Contributor

slemeur commented Jul 19, 2017

thanks @svor !

@codenvy-ci
Copy link

Build # 3114 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/3114/ to view the results.

@codenvy-ci
Copy link

@svor svor merged commit 6c6e00e into master Jul 20, 2017
@svor svor deleted the CHE-5473 branch July 20, 2017 06:49
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants