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

@Factory with dataProvider changes order of iterations #1454

Closed

Conversation

krmahadevan
Copy link
Member

@krmahadevan krmahadevan commented Jun 20, 2017

Closes #799

Fixes #799 .

Did you remember to?

  • Add test case(s)
  • Update CHANGES.txt

We encourage pull requests that:

  • Add new features to TestNG (or)
  • Fix bugs in TestNG

If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.

Copy link
Member

@juherr juherr left a comment

Choose a reason for hiding this comment

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

I'm not feeling good the modification of current tests. In few words, could you explain why we need it?

@@ -242,7 +244,7 @@ protected static void addMethods(XmlClass cls, String... methods) {
}

public static String getPathToResource(String fileName) {
String result = System.getProperty(TEST_RESOURCES_DIR);
String result = System.getProperty(TEST_RESOURCES_DIR,"src/test/resources");
Copy link
Member

Choose a reason for hiding this comment

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

A space is missing

doAssert(actual, Arrays.asList(expectedValues));
}

protected static void doAssert(List<String> actual, List<String> expected) {
Copy link
Member

Choose a reason for hiding this comment

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

I think AssertJ has already the expected assertion.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure if AssertJ had it or not because am not very familiar with AssertJ. I will try and revisit it and see if I can find it. If yes, then I will address this.

@@ -36,7 +38,8 @@ public void includedGroups() {

tng.run();

assertThat(listener.getSucceedMethodNames()).containsExactly("method1", "method3");
List<String> expected = Arrays.asList("method1", "method3");
doAssert(listener.getSucceedMethodNames(), expected);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the modification of the current tests (except if the order is wrong).
Instead, we should try to keep the previous behavior.
An option could be to introduce a new edge between tests of the same class.

Copy link
Member Author

Choose a reason for hiding this comment

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

All the tests that have been modified are only making themselves agnostic to the order of the test methods. The current tests have all had this hard wired into them. The moment I removed off the ordering, the tests started breaking because now the order is all governed by how Java's reflection yields those methods.

An option could be to introduce a new edge between tests of the same class.

Where would that new option reside ? It would be good if you can please help add more context.

Copy link
Member

Choose a reason for hiding this comment

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

the order is all governed by how Java's reflection yields those methods

Does it mean it could change with different java version? Or it is the order in the file from top to bottom?
The problem is the modification of the current behavior.

Where would that new option reside?
Just an idea: It could be something like "alphaOrder" where methods of a class will be sorted by their name and linked together.
The goal is to have a way to keep the current behavior (or have a way to restore it).

Copy link
Member Author

Choose a reason for hiding this comment

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

@juherr - As per this StackOverFlow post, it looks like the order is not defined. Since the order is not defined, there's no predicting on how it could be.

Just an idea: It could be something like "alphaOrder" where methods of a class will be sorted by their name and linked together.

Sounds good. But I would be glad if you could please help call out as to where would this option/configuration reside. Is it from within the TestNG DTD or via a JVM argument or something on that lines ? The JVM argument would be the easiest to do.

@krmahadevan
Copy link
Member Author

I'm not feeling good the modification of current tests. In few words, could you explain why we need it?

@juherr - The changes to the tests have been done only to make them agnostic to the order of the method execution. The current implementation has them adhere to ordering, but since I removed the sorting and eventually the ordering, the tests started breaking because AssertJ APIs in terms of assertions for collections also honors the order, apart from the contents of the collection.

All said and done, I still have 2 tests from the parallel test execution which are breaking. I haven't been able to crack the reason of the failure. I raised this PR because that was the only way in which I was able to get travis to give me feedback. Running the build locally on my Mac was taking ~30+ minutes for the tests to run to completion (Remember I had sent you and @cbeust an email about elongated build times due to long running tests ? I still have that problem and haven't found a solution. ). So until this PR turns all the tests green, this PR is not good to be merged.

@juherr
Copy link
Member

juherr commented Jun 21, 2017

I'm fine with the goal of the PR if we keep some tests that enforce the order :)

About your time issue, I don't have a Mac for the moment, so I can't reproduce the issue. Maybe it is caused by gradle/gradle#736

@krmahadevan
Copy link
Member Author

About your time issue, I don't have a Mac for the moment, so I can't reproduce the issue. Maybe it is caused by gradle/gradle#736

@juherr - Bingo! That was the answer... I updated my /etc/hosts file to include the hostname value as per the output of hostname and then re-ran the build. Now I am back to under 5 mins as build time.. Thank you so much..

@cbeust
Copy link
Collaborator

cbeust commented Jun 21, 2017

I believe that was my first suggestion when you mentioned your problem, that it was probably some DNS resolution issue. Glad you figured it out.

@krmahadevan
Copy link
Member Author

@cbeust - Yes, it was. But I didn't understand the relevance of the DNS to this issue and how to go about fixing it(my bad). That was why I was going around in circles.

@krmahadevan
Copy link
Member Author

@juherr - I am for now closing off this PR since as we discussed this needs more work to be done. Will submit a new one once I have something concrete on this.

@juherr
Copy link
Member

juherr commented Jun 22, 2017

@krmahadevan 👍
Fyi, if you need Travis feedbacks, you can configure it for your own repo too.
Just login there and activate it. It should work.

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

Successfully merging this pull request may close these issues.

@Factory with dataProvider changes order of iterations
3 participants