List Info

Thread: Sorter in JUnit 4.5




Sorter in JUnit 4.5
country flaguser name
United States
2008-07-02 01:38:41

Hi!

I have implemented a very straight-forward sorter that runs fine in
JUnit up to version 4.4 but not in 4.5 beta. Here is the sorter:

public class InternalTestClassArraySorter extends Sorter {
public InternalTestClassArraySorter(Comparator<Description> comparator) {
super(comparator);
}

Override
public int compare(Description o1, Description o2) {
System.out.println("Comparing" + o1 + " and " + o2);
return super.compare(o1, o2);
}

public void apply(Object runner) {
super.apply((Runner)runner);
}


public static class MethodNameComparator implements
Comparator<Description> {
public int compare(Description o1, Description o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
}
}

And here is the according runner:

public class SortedSkipRunner extends Parameterized {
private static final Configuration config;
private final PropertyMethodSkipFilter filter;
private final Sorter sorter;

static {
config = new Configuration();
}

public SortedSkipRunner(Class<?> klass) throws Throwable {
super(klass);

filter = new PropertyMethodSkipFilter();
filter.setConfig(config);
this.filter(filter);

sorter = new InternalTestClassArraySorter(new
InternalTestClassArraySorter.MethodNameComparator());
this.sort(sorter);
}

public static Configuration getConfig() {
return config;
}
}

Basically it should sort the test-methods by the name of the test
method. I do apply it via the sort-method in my Runner. But somehow
the sorter is ignored by my test-execution. Any guess what is going
wrong here?

Thanks & Best Regards,
Robin

__._,_.___
.

__,_._,___
RE: Sorter in JUnit 4.5
country flaguser name
United States
2008-07-10 13:51:31

Robin,

We were able to reproduce the defect your found with a simple test. Indeed,
filters and sorters don't work correctly in all cases in 4.5 compared to
4.4. We will fix this defect before releasing. Thank you for the clear
example--that made diagnosis much easier even though fixing it is turning
out to be difficult.

Regards,

Kent Beck
Three Rivers Institute

_____

From: junit%40yahoogroups.com">junityahoogroups.com [mailto: junit%40yahoogroups.com">junityahoogroups.com] On Behalf Of
robinjay33
Sent: Tuesday, July 01, 2008 11:39 PM
To: junit%40yahoogroups.com">junityahoogroups.com
Subject: [junit] Sorter in JUnit 4.5

Hi!

I have implemented a very straight-forward sorter that runs fine in
JUnit up to version 4.4 but not in 4.5 beta. Here is the sorter:

public class InternalTestClassArraySorter extends Sorter {
public InternalTestClassArraySorter(Comparator&lt;Description> comparator) {
super(comparator);
}

Override
public int compare(Description o1, Description o2) {
System.out.println("Comparing&quot; + o1 + " and " + o2);
return super.compare(o1, o2);
}

public void apply(Object runner) {
super.apply((Runner)runner);
}

public static class MethodNameComparator implements
Comparator<Description> {
public int compare(Description o1, Description o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
}
}

And here is the according runner:

public class SortedSkipRunner extends Parameterized {
private static final Configuration config;
private final PropertyMethodSkipFilter filter;
private final Sorter sorter;

static {
config = new Configuration();
}

public SortedSkipRunner(Class<?> klass) throws Throwable {
super(klass);

filter = new PropertyMethodSkipFilter();
filter.setConfig(config);
this.filter(filter);

sorter = new InternalTestClassArraySorter(new
InternalTestClassArraySorter.MethodNameComparator());
this.sort(sorter);
}

public static Configuration getConfig() {
return config;
}
}

Basically it should sort the test-methods by the name of the test
method. I do apply it via the sort-method in my Runner. But somehow
the sorter is ignored by my test-execution. Any guess what is going
wrong here?

Thanks & Best Regards,
Robin

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )