You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(80) |
Nov
(42) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(50) |
Mar
(70) |
Apr
(102) |
May
(28) |
Jun
(45) |
Jul
(14) |
Aug
(75) |
Sep
(17) |
Oct
(15) |
Nov
(11) |
Dec
(4) |
2003 |
Jan
(16) |
Feb
(19) |
Mar
(21) |
Apr
(20) |
May
(29) |
Jun
(7) |
Jul
(5) |
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(3) |
2004 |
Jan
(5) |
Feb
(4) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(6) |
Oct
(6) |
Nov
(1) |
Dec
(2) |
2005 |
Jan
(4) |
Feb
(4) |
Mar
(15) |
Apr
(1) |
May
|
Jun
(4) |
Jul
(6) |
Aug
(6) |
Sep
|
Oct
(4) |
Nov
(2) |
Dec
(4) |
2006 |
Jan
|
Feb
(91) |
Mar
(47) |
Apr
(7) |
May
(4) |
Jun
(9) |
Jul
(1) |
Aug
|
Sep
(5) |
Oct
(36) |
Nov
(95) |
Dec
(12) |
2007 |
Jan
(11) |
Feb
(31) |
Mar
(45) |
Apr
(11) |
May
(9) |
Jun
(1) |
Jul
(146) |
Aug
(15) |
Sep
|
Oct
(3) |
Nov
(6) |
Dec
(1) |
2008 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(2) |
Aug
(19) |
Sep
(1) |
Oct
(10) |
Nov
|
Dec
(8) |
2009 |
Jan
(3) |
Feb
(1) |
Mar
(4) |
Apr
(8) |
May
(5) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
(2) |
Oct
(13) |
Nov
(13) |
Dec
(4) |
2010 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(2) |
May
|
Jun
(1) |
Jul
(3) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
(1) |
Feb
(4) |
Mar
(3) |
Apr
(4) |
May
|
Jun
(12) |
Jul
(16) |
Aug
(4) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/tests Modified Files: AssumptionTest.java Log Message: Re-organize theory packages Index: AssumptionTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/AssumptionTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AssumptionTest.java 6 Jul 2007 16:04:09 -0000 1.2 +++ AssumptionTest.java 12 Jul 2007 17:08:26 -0000 1.3 @@ -5,7 +5,7 @@ import static org.junit.Assume.assumeNoException; import static org.junit.Assume.assumeNotNull; import static org.junit.Assume.assumeThat; -import static org.junit.experimental.theories.matchers.api.StringContains.containsString; +import static org.junit.matchers.StringContains.containsString; import org.junit.Assume; import org.junit.Test; |
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/matchers In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/matchers Added Files: IsCollectionContaining.java TypeSafeMatcher.java StringContains.java Each.java SubstringMatcher.java Log Message: Re-organize theory packages --- NEW FILE: IsCollectionContaining.java --- package org.junit.matchers; import static org.hamcrest.core.AllOf.allOf; import static org.hamcrest.core.IsEqual.equalTo; import java.util.ArrayList; import java.util.Collection; import org.hamcrest.Description; import org.hamcrest.Factory; import org.hamcrest.Matcher; // Copied (hopefully temporarily) from hamcrest-library public class IsCollectionContaining<T> extends TypeSafeMatcher<Iterable<T>> { private final Matcher<? extends T> elementMatcher; public IsCollectionContaining(Matcher<? extends T> elementMatcher) { this.elementMatcher = elementMatcher; } @Override public boolean matchesSafely(Iterable<T> collection) { for (T item : collection) { if (elementMatcher.matches(item)){ return true; } } return false; } public void describeTo(Description description) { description .appendText("a collection containing ") .appendDescriptionOf(elementMatcher); } @Factory public static <T> Matcher<Iterable<T>> hasItem(Matcher<? extends T> elementMatcher) { return new IsCollectionContaining<T>(elementMatcher); } @Factory public static <T> Matcher<Iterable<T>> hasItem(T element) { return hasItem(equalTo(element)); } @Factory public static <T> Matcher<Iterable<T>> hasItems(Matcher<? extends T>... elementMatchers) { Collection<Matcher<? extends Iterable<T>>> all = new ArrayList<Matcher<? extends Iterable<T>>>(elementMatchers.length); for (Matcher<? extends T> elementMatcher : elementMatchers) { all.add(hasItem(elementMatcher)); } return allOf(all); } @Factory public static <T> Matcher<Iterable<T>> hasItems(T... elements) { Collection<Matcher<? extends Iterable<T>>> all = new ArrayList<Matcher<? extends Iterable<T>>>(elements.length); for (T element : elements) { all.add(hasItem(element)); } return allOf(all); } } --- NEW FILE: TypeSafeMatcher.java --- package org.junit.matchers; import java.lang.reflect.Method; import org.hamcrest.BaseMatcher; /** * Convenient base class for Matchers that require a non-null value of a specific type. * This simply implements the null check, checks the type and then casts. * * @author Joe Walnes */ public abstract class TypeSafeMatcher<T> extends BaseMatcher<T> { private Class<?> expectedType; /** * Subclasses should implement this. The item will already have been checked for * the specific type and will never be null. */ public abstract boolean matchesSafely(T item); protected TypeSafeMatcher() { expectedType = findExpectedType(getClass()); } private static Class<?> findExpectedType(Class<?> fromClass) { for (Class<?> c = fromClass; c != Object.class; c = c.getSuperclass()) { for (Method method : c.getDeclaredMethods()) { if (isMatchesSafelyMethod(method)) { return method.getParameterTypes()[0]; } } } throw new Error("Cannot determine correct type for matchesSafely() method."); } private static boolean isMatchesSafelyMethod(Method method) { return method.getName().equals("matchesSafely") && method.getParameterTypes().length == 1 && !method.isSynthetic(); } protected TypeSafeMatcher(Class<T> expectedType) { this.expectedType = expectedType; } /** * Method made final to prevent accidental override. * If you need to override this, there's no point on extending TypeSafeMatcher. * Instead, extend the {@link BaseMatcher}. */ @SuppressWarnings({"unchecked"}) public final boolean matches(Object item) { return item != null && expectedType.isInstance(item) && matchesSafely((T) item); } } --- NEW FILE: StringContains.java --- /* Copyright (c) 2000-2006 hamcrest.org */ package org.junit.matchers; import org.hamcrest.Factory; import org.hamcrest.Matcher; /** * Tests if the argument is a string that contains a substring. */ public class StringContains extends SubstringMatcher { public StringContains(String substring) { super(substring); } @Override protected boolean evalSubstringOf(String s) { return s.indexOf(substring) >= 0; } @Override protected String relationship() { return "containing"; } @Factory public static Matcher<String> containsString(String substring) { return new StringContains(substring); } } --- NEW FILE: Each.java --- package org.junit.matchers; import static org.hamcrest.CoreMatchers.not; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; import static org.junit.matchers.IsCollectionContaining.hasItem; public class Each { public static <T> Matcher<Iterable<T>> each(final Matcher<T> individual) { final Matcher<Iterable<T>> allItemsAre = not(hasItem(not(individual))); return new BaseMatcher<Iterable<T>>() { public boolean matches(Object item) { return allItemsAre.matches(item); } public void describeTo(Description description) { description.appendText("each "); individual.describeTo(description); } }; } } --- NEW FILE: SubstringMatcher.java --- package org.junit.matchers; import org.hamcrest.Description; public abstract class SubstringMatcher extends TypeSafeMatcher<String> { // TODO: Replace String with CharSequence to allow for easy interopability between // String, StringBuffer, StringBuilder, CharBuffer, etc (joe). protected final String substring; protected SubstringMatcher(final String substring) { this.substring = substring; } @Override public boolean matchesSafely(String item) { return evalSubstringOf(item); } public void describeTo(Description description) { description.appendText("a string ") .appendText(relationship()) .appendText(" ") .appendValue(substring); } protected abstract boolean evalSubstringOf(String string); protected abstract String relationship(); } |
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/assertion In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test/assertion Added Files: AssumptionViolatedExceptionTest.java Log Message: Re-organize theory packages --- NEW FILE: AssumptionViolatedExceptionTest.java --- package org.junit.experimental.test.assertion; import static org.junit.matchers.StringContains.containsString; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import org.hamcrest.Matcher; import org.hamcrest.StringDescription; import org.junit.Test; import org.junit.Assume.AssumptionViolatedException; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.RunWith; @RunWith(Theories.class) public class AssumptionViolatedExceptionTest { public static Object TWO= 2; public static Matcher<?> IS_THREE= is(3); @Theory public void toStringIsUseful(Object actual, Matcher<?> matcher) { assertThat(new AssumptionViolatedException(actual, matcher).toString(), containsString(matcher.toString())); } @Test public void AssumptionViolatedExceptionDescribesItself() { AssumptionViolatedException e= new AssumptionViolatedException(3, is(2)); assertThat(StringDescription.asString(e), is("got: <3>, expected: is <2>")); } } |
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/matchers In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test/matchers Removed Files: EachTest.java MatcherCharacterization.java StackTraceTest.java ClassNamedMatcherTest.java CamelCaseNameTest.java MethodNamedMatcherTest.java Log Message: Re-organize theory packages --- EachTest.java DELETED --- --- MatcherCharacterization.java DELETED --- --- StackTraceTest.java DELETED --- --- ClassNamedMatcherTest.java DELETED --- --- CamelCaseNameTest.java DELETED --- --- MethodNamedMatcherTest.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/javamodel/api In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/javamodel/api Removed Files: ConcreteFunction.java Function.java Log Message: Re-organize theory packages --- ConcreteFunction.java DELETED --- --- Function.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test Added Files: TheoryTests.java Log Message: Re-organize theory packages --- NEW FILE: TheoryTests.java --- package org.junit.experimental.test; import org.junit.experimental.test.assertion.AssumptionViolatedExceptionTest; import org.junit.experimental.test.imposterization.AssumePassingTest; import org.junit.experimental.test.imposterization.PopperImposterizerTest; import org.junit.experimental.test.imposterization.ThrownMatcherTest; import org.junit.experimental.test.javamodel.ConcreteFunctionTest; import org.junit.experimental.test.javamodel.FunctionTest; import org.junit.experimental.test.matchers.EachTest; import org.junit.experimental.test.matchers.MatcherCharacterization; import org.junit.experimental.test.results.PrintableResultTest; import org.junit.experimental.test.results.ResultMatchersTest; import org.junit.experimental.test.runner.DataPointMethodTest; import org.junit.experimental.test.runner.ParameterizedAssertionErrorTest; import org.junit.experimental.test.runner.TheoriesTest; import org.junit.experimental.test.runner.TheoryContainerReferenceTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses( { AssumptionViolatedExceptionTest.class, ConcreteFunctionTest.class, EachTest.class, MatcherCharacterization.class, ParameterizedAssertionErrorTest.class, TheoriesTest.class, TheoryContainerReferenceTest.class, FunctionTest.class, PrintableResultTest.class, ResultMatchersTest.class, DataPointMethodTest.class, AssumePassingTest.class, PopperImposterizerTest.class, ThrownMatcherTest.class }) public class TheoryTests { } |
From: David S. <ds...@us...> - 2007-07-12 17:08:34
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/imposterization In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test/imposterization Added Files: ThrownMatcherTest.java AssumePassingTest.java PopperImposterizerTest.java Log Message: Re-organize theory packages --- NEW FILE: ThrownMatcherTest.java --- package org.junit.experimental.test.imposterization; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.junit.matchers.StringContains.containsString; import java.util.ArrayList; import org.junit.Test; import org.junit.experimental.imposterization.ThrownMatcher; import org.junit.experimental.imposterization.ThrownMatcher.IncorrectThrownException; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.RunWith; @RunWith(Theories.class) public class ThrownMatcherTest { @Test public void assertThrownVerifiesExceptionThrown() throws Exception { ArithmeticException ae= new ArithmeticException(); try { ThrownMatcher.assertThrownException(is(ae)).when( new ArrayList<String>()).get(0); fail("should have thrown exception"); } catch (IncorrectThrownException e) { assertThat(e.getMessage(), containsString(ae.toString())); } } @Test public void assertThrownVerifiesExceptionThrownWithRequirements() throws Exception { ArithmeticException ae= new ArithmeticException(); try { ThrownMatcher.assertThrownException(is(ae)).when( new ArrayList<String>()).get(0); fail("should have thrown exception"); } catch (IncorrectThrownException e) { assertThat(e.getMessage(), containsString(ae.toString())); } } public static class ExceptionThrowing { public static Throwable EXCEPTION= new NullPointerException(); public void liveDangerously() throws Throwable { throw EXCEPTION; } } @Test public void stackTraceOnAssertThrown() { try { ThrownMatcher.assertThrownException(is(new RuntimeException())) .when(new ExceptionThrowing()).liveDangerously(); fail("should have thrown exception"); } catch (Throwable e) { assertThat(e.getCause(), is(ExceptionThrowing.EXCEPTION)); } } } --- NEW FILE: AssumePassingTest.java --- package org.junit.experimental.test.imposterization; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import static org.junit.experimental.imposterization.AssumePassing.assumePasses; import java.util.List; import org.junit.Test; import org.junit.Assume.AssumptionViolatedException; import org.junit.experimental.imposterization.AssumePassing; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.JUnitCore; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; @RunWith(Theories.class) public class AssumePassingTest { public static class OnlyIfPassingButDoesnt { @Test public void failing() { fail(); } @SuppressWarnings("deprecation") @Test public void willIgnore() { ((OnlyIfPassingButDoesnt) AssumePassing.assumePasses(this .getClass())).failing(); fail(); } } @Test public void onlyIfPassingButDoesnt() { assertThat(onlyIfPassingFailures().size(), is(1)); } @SuppressWarnings("unchecked") @Test public void removedParameterizedFailureWhenZeroParams() { assertThat(onlyIfPassingFailures().get(0).getException(), is(AssertionError.class)); } private List<Failure> onlyIfPassingFailures() { return JUnitCore.runClasses(OnlyIfPassingButDoesnt.class).getFailures(); } @RunWith(Theories.class) public static class OnlyIfPassesAndDoes { @Test public void passing() { } @SuppressWarnings("deprecation") @Test public void wontIgnore() { assumePasses(OnlyIfPassesAndDoes.class).passing(); fail(); } } @Test public void onlyIfPassesAndDoes() { assertThat(JUnitCore.runClasses(OnlyIfPassesAndDoes.class) .getFailures().size(), is(1)); } @RunWith(Theories.class) public static class OnlyIfPassesWithInvalidTheory { @Test public void throwsInvalidTheory() { throw new AssumptionViolatedException(null, is("a")); } @SuppressWarnings("deprecation") @Test public void wontIgnore() { assumePasses(OnlyIfPassesWithInvalidTheory.class) .throwsInvalidTheory(); } } @Test public void onlyIfPassesWithInvalidTheory() { assertThat(JUnitCore.runClasses(OnlyIfPassesWithInvalidTheory.class) .getIgnoreCount(), is(0)); } } --- NEW FILE: PopperImposterizerTest.java --- package org.junit.experimental.test.imposterization; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; import java.util.List; import org.junit.Test; import org.junit.experimental.imposterization.PopperImposterizer; public class PopperImposterizerTest { @Test public void canWrapImposterizedObjects() { List<?> list= new PopperImposterizer(null).imposterize(List.class); assertThat(new PopperImposterizer(null).imposterize(list.getClass()), notNullValue()); } } |
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/runner In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test/runner Removed Files: TheoriesTest.java DataPointMethodTest.java ParameterizedAssertionErrorTest.java TheoryContainerReferenceTest.java Log Message: Re-organize theory packages --- TheoriesTest.java DELETED --- --- DataPointMethodTest.java DELETED --- --- ParameterizedAssertionErrorTest.java DELETED --- --- TheoryContainerReferenceTest.java DELETED --- |
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/runner In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test/runner Added Files: TheoryContainerReferenceTest.java DataPointMethodTest.java TheoriesTest.java ParameterizedAssertionErrorTest.java Log Message: Re-organize theory packages --- NEW FILE: TheoryContainerReferenceTest.java --- package org.junit.experimental.test.runner; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; import java.util.Date; import java.util.List; import org.junit.Test; import org.junit.experimental.imposterization.FunctionPointer; import org.junit.experimental.theories.methods.api.DataPoint; import org.junit.experimental.theories.methods.api.ParameterSignature; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.TheoryContainerReference; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.RunWith; import static org.junit.matchers.StringContains.containsString; public class TheoryContainerReferenceTest { private FunctionPointer method = new FunctionPointer(); private final HasDataPointMethod test = new HasDataPointMethod(); @RunWith(Theories.class) public static class HasDataPointMethod { @DataPoint public int oneHundred() { return 100; } public Date notADataPoint() { return new Date(); } @Theory public void allIntsOk(int x) { } @Theory public void onlyStringsOk(String s) { } @Theory public void onlyDatesOk(Date d) { } } @Test public void pickUpDataPointMethods() throws SecurityException, InstantiationException, IllegalAccessException { method.calls(test).allIntsOk(0); assertThat(potentialValues().toString(), containsString("100")); } @Test public void ignoreDataPointMethodsWithWrongTypes() throws SecurityException, InstantiationException, IllegalAccessException { method.calls(test).onlyStringsOk(null); assertThat(potentialValues().toString(), not(containsString("100"))); } @Test public void ignoreDataPointMethodsWithoutAnnotation() throws SecurityException, InstantiationException, IllegalAccessException { method.calls(test).onlyDatesOk(null); assertThat(potentialValues().size(), is(0)); } private List<?> potentialValues() throws InstantiationException, IllegalAccessException { return new TheoryContainerReference(test) .getPotentialValues(ParameterSignature.signatures( method.getMethod()).get(0)); } } --- NEW FILE: DataPointMethodTest.java --- package org.junit.experimental.test.runner; import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; import static org.junit.matchers.Each.each; import java.util.List; import org.hamcrest.Matcher; import org.junit.Test; import org.junit.experimental.theories.methods.api.DataPoint; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.JUnitCore; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; public class DataPointMethodTest { @RunWith(Theories.class) public static class HasDataPointMethod { @DataPoint public int oneHundred() { return 100; } @Theory public void allIntsOk(int x) { } } @RunWith(Theories.class) public static class HasUglyDataPointMethod { @DataPoint public int oneHundred() { return 100; } @DataPoint public int oneUglyHundred() { throw new RuntimeException(); } @Theory public void allIntsOk(int x) { } } @Test public void pickUpDataPointMethods() { assertThat(failures(HasDataPointMethod.class), empty()); } @Test public void ignoreExceptionsFromDataPointMethods() { assertThat(failures(HasUglyDataPointMethod.class), empty()); } private List<Failure> failures(Class<?> type) { return JUnitCore.runClasses(type).getFailures(); } private Matcher<Iterable<Failure>> empty() { Matcher<Failure> nullValue= nullValue(); return each(nullValue); } } --- NEW FILE: TheoriesTest.java --- package org.junit.experimental.test.runner; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; import static org.junit.Assume.assumeThat; import static org.junit.experimental.results.ResultMatchers.failureCountIs; import static org.junit.experimental.results.ResultMatchers.hasSingleFailureContaining; import static org.junit.matchers.StringContains.containsString; import org.hamcrest.Matcher; import org.junit.Test; import org.junit.experimental.results.PrintableResult; import org.junit.experimental.results.ResultMatchers; import org.junit.experimental.theories.methods.api.TestedOn; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.api.Theories; import org.junit.internal.runners.TestClass; import org.junit.runner.RunWith; @SuppressWarnings("restriction") @RunWith(Theories.class) public class TheoriesTest { public static String SPACE= " "; public static String J= "J"; public static String NULL_STRING= null; public static int ZERO= 0; public static int ONE= 1; public static int THREE= 3; public static int FIVE= 5; public static int INDEPENDENCE = 1776; public static Matcher<Integer> NOT_ZERO= not(0); public static Matcher<Integer> IS_ONE= is(1); @RunWith(Theories.class) public static class HasATheory { public static int ONE= 1; @Theory public void everythingIsZero(int x) { assertThat(x, is(0)); } } @Test public void theoryClassMethodsShowUp() throws Exception { assertThat(new Theories(HasATheory.class).getDescription() .getChildren().size(), is(1)); } @Test public void theoryAnnotationsAreRetained() throws Exception { assertThat(new TestClass(HasATheory.class).getAnnotatedMethods( Theory.class).size(), is(1)); } @Test public void canRunTheories() throws Exception { assertThat(PrintableResult.testResult(HasATheory.class), hasSingleFailureContaining("Expected")); } @RunWith(Theories.class) public static class HasATwoParameterTheory { public static int ONE= 1; @Theory public void everythingIsZero(int x, int y) { assertThat(x, is(y)); } } @Test public void canRunTwoParameterTheories() throws Exception { assertThat(PrintableResult.testResult(HasATwoParameterTheory.class), ResultMatchers.isSuccessful()); } @RunWith(Theories.class) public static class DoesntUseParams { public static int ONE= 1; @Theory public void everythingIsZero(int x, int y) { assertThat(2, is(3)); } } @Test public void reportBadParams() throws Exception { assertThat(PrintableResult.testResult(DoesntUseParams.class), hasSingleFailureContaining("everythingIsZero(1, 1)")); } @RunWith(Theories.class) public static class NullsOK { public static String NULL= null; public static String A= "A"; @Theory public void everythingIsA(String a) { assertThat(a, is("A")); } } @Test public void nullsUsedUnlessProhibited() throws Exception { assertThat(PrintableResult.testResult(NullsOK.class), hasSingleFailureContaining("null")); } @RunWith(Theories.class) public static class ParameterAnnotations { @Theory public void everythingIsOne(@TestedOn(ints= { 1 }) int number) { assertThat(number, is(1)); } } @Test public void testedOnLimitsParameters() throws Exception { assertThat(PrintableResult.testResult(ParameterAnnotations.class), ResultMatchers.isSuccessful()); } @RunWith(Theories.class) public static class HonorExpectedException { @Test(expected= NullPointerException.class) public void shouldThrow() { } } @Test public void honorExpected() throws Exception { assertThat(PrintableResult.testResult(HonorExpectedException.class) .getFailures().size(), is(1)); } @RunWith(Theories.class) public static class HonorTimeout { @Test(timeout = 5) public void shouldStop() throws InterruptedException { while(true) { Thread.sleep(1000); } } } @Test public void honorTimeout() throws Exception { assertThat(PrintableResult.testResult(HonorTimeout.class), failureCountIs(1)); } @RunWith(Theories.class) public static class AssumptionsFail { public static int DATA= 0; public static Matcher<Integer> MATCHER= null; @Theory public void nonZeroIntsAreFun(int x) { assumeThat(x, MATCHER); } } @Theory public void showFailedAssumptionsWhenNoParametersFound(int data, Matcher<Integer> matcher) throws Exception { assumeThat(data, not(matcher)); AssumptionsFail.DATA= data; AssumptionsFail.MATCHER= matcher; String result= PrintableResult.testResult(AssumptionsFail.class) .toString(); assertThat(result, containsString(matcher.toString())); assertThat(result, containsString("" + data)); } } --- NEW FILE: ParameterizedAssertionErrorTest.java --- package org.junit.experimental.test.runner; import static org.junit.matchers.StringContains.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; import static org.junit.Assume.assumeThat; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.ParameterizedAssertionError; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.RunWith; @RunWith(Theories.class) public class ParameterizedAssertionErrorTest { public static final String METHOD_NAME= "methodName"; public static final NullPointerException NULL_POINTER_EXCEPTION= new NullPointerException(); public static Object[] NO_OBJECTS= new Object[0]; public static ParameterizedAssertionError A= new ParameterizedAssertionError( NULL_POINTER_EXCEPTION, METHOD_NAME); public static ParameterizedAssertionError B= new ParameterizedAssertionError( NULL_POINTER_EXCEPTION, METHOD_NAME); public static ParameterizedAssertionError B2= new ParameterizedAssertionError( NULL_POINTER_EXCEPTION, "methodName2"); @Theory public void equalParameterizedAssertionErrorsHaveSameToString( ParameterizedAssertionError a, ParameterizedAssertionError b) { assumeThat(a, is(b)); assertThat(a.toString(), is(b.toString())); } @Theory public void differentParameterizedAssertionErrorsHaveDifferentToStrings( ParameterizedAssertionError a, ParameterizedAssertionError b) { assumeThat(a, not(b)); assertThat(a.toString(), not(b.toString())); } @Theory public void equalsReturnsTrue(Throwable targetException, String methodName, Object[] params) { assertThat(new ParameterizedAssertionError(targetException, methodName, params), is(new ParameterizedAssertionError(targetException, methodName, params))); } @SuppressWarnings("unchecked") @Theory(nullsAccepted= false) public void buildParameterizedAssertionError(String methodName, String param) { assertThat(new ParameterizedAssertionError(new RuntimeException(), methodName, param).toString(), containsString(methodName)); } } |
From: David S. <ds...@us...> - 2007-07-12 17:08:33
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/assertion In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test/assertion Removed Files: AssumptionViolatedExceptionTest.java Log Message: Re-organize theory packages --- AssumptionViolatedExceptionTest.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:33
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test Removed Files: TheoryTests.java Log Message: Re-organize theory packages --- TheoryTests.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:33
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/runner/api In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/runner/api Modified Files: Theories.java Log Message: Re-organize theory packages Index: Theories.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/experimental/theories/runner/api/Theories.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Theories.java 2 Jul 2007 18:11:14 -0000 1.1 +++ Theories.java 12 Jul 2007 17:08:26 -0000 1.2 @@ -3,67 +3,17 @@ */ package org.junit.experimental.theories.runner.api; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Assume.AssumptionViolatedException; -import org.junit.experimental.theories.javamodel.api.ConcreteFunction; import org.junit.experimental.theories.methods.api.Theory; -import org.junit.experimental.theories.runner.TheoryContainerReference; +import org.junit.experimental.theories.runner.TheoryMethod; import org.junit.internal.runners.InitializationError; import org.junit.internal.runners.JUnit4ClassRunner; -import org.junit.internal.runners.TestClass; import org.junit.internal.runners.TestMethod; @SuppressWarnings("restriction") public class Theories extends JUnit4ClassRunner { - public static class TheoryMethod extends TestMethod { - private final Method fMethod; - - private List<AssumptionViolatedException> fInvalidParameters= new ArrayList<AssumptionViolatedException>(); - - private TheoryMethod(Method method, TestClass testClass) { - super(method, testClass); - fMethod= method; - } - - @Override - public void invoke(Object test) throws IllegalArgumentException, - IllegalAccessException, InvocationTargetException { - TheoryContainerReference container= new TheoryContainerReference( - test); - - ConcreteFunction function= new ConcreteFunction(test, fMethod); - - int runCount= 0; - try { - runCount+= container.runWithParameters(this, - new ArrayList<Object>(), function.signatures()); - } catch (Throwable e) { - throw new InvocationTargetException(e); - } - if (runCount == 0) - Assert - .fail("Never found parameters that satisfied method. Violated assumptions: " - + fInvalidParameters); - } - - public boolean nullsOk() { - return fMethod.getAnnotation(Theory.class).nullsAccepted(); - } - - public Method getMethod() { - return fMethod; - } - - public void addAssumptionFailure(AssumptionViolatedException e) { - fInvalidParameters.add(e); - } - } - @Override protected void validate() throws InitializationError { } |
From: David S. <ds...@us...> - 2007-07-12 17:08:28
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/javamodel In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test/javamodel Added Files: FunctionTest.java ConcreteFunctionTest.java Log Message: Re-organize theory packages --- NEW FILE: FunctionTest.java --- package org.junit.experimental.test.javamodel; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; import org.junit.Before; import org.junit.Test; import org.junit.experimental.imposterization.FunctionPointer; import org.junit.experimental.theories.methods.api.TestedOn; public class FunctionTest { public static class HasAnnotation { public void something(@TestedOn(ints= { 3 }) int x) { } } FunctionPointer function= FunctionPointer.pointer(); @Before public void functionPoints() { function.calls(new HasAnnotation()).something(4); } @SuppressWarnings("unchecked") @Test public void getSupplierAnnotation() { assertThat(function.signatures().get(0).getSupplierAnnotation(), is(TestedOn.class)); } @Test public void thrownReturnsNullIfNormalReturn() { assertThat(function.exceptionThrown(4), nullValue()); } } --- NEW FILE: ConcreteFunctionTest.java --- package org.junit.experimental.test.javamodel; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; import static org.junit.Assume.assumeThat; import static org.junit.matchers.StringContains.containsString; import java.lang.reflect.Method; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.ConcreteFunction; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.RunWith; @RunWith(Theories.class) public class ConcreteFunctionTest { public static Method TO_STRING; public static Method WAIT; static { try { TO_STRING= Object.class.getMethod("toString"); WAIT= Object.class.getMethod("wait"); } catch (Exception e) { e.printStackTrace(); } } public static ConcreteFunction zeroToString1= new ConcreteFunction(0, TO_STRING); public static ConcreteFunction zeroToString2= new ConcreteFunction(0, TO_STRING); public static ConcreteFunction oneToString1= new ConcreteFunction(1, TO_STRING); public static ConcreteFunction oneFinalize= new ConcreteFunction(1, WAIT); public static String ROB_KUTNER= "Rob Kutner"; @Theory public void unequalToStringsMeansFunctionsUnequal(ConcreteFunction a, ConcreteFunction b) { assumeThat(a.toString(), not(b.toString())); assertThat(a, not(b)); } @Theory public void unequalMethodsMeansUnequalFunctions(Method m1, Method m2, Object o) { assumeThat(m1, not(m2)); assertThat(new ConcreteFunction(o, m1), not(new ConcreteFunction(o, m2))); } @Theory public void unequalFunctionsMeanUnequalToStrings(ConcreteFunction a, ConcreteFunction b) { assumeThat(a, not(b)); assertThat(a.toString(), not(b.toString())); } @SuppressWarnings("unchecked") @Theory public void throwsUsefulErrorWhenParameterNumberWrong(String string) throws Throwable { try { new ConcreteFunction(this, TO_STRING).invoke(string); } catch (Exception e) { assertThat(e.toString(), allOf(containsString(string), containsString(TO_STRING.toString()))); } } } |
From: David S. <ds...@us...> - 2007-07-12 17:08:25
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/imposterization In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test/imposterization Removed Files: PopperImposterizerTest.java ThrownMatcherTest.java AssumePassingTest.java Log Message: Re-organize theory packages --- PopperImposterizerTest.java DELETED --- --- ThrownMatcherTest.java DELETED --- --- AssumePassingTest.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:25
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/matchers In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test/matchers Added Files: MatcherCharacterization.java EachTest.java Log Message: Re-organize theory packages --- NEW FILE: MatcherCharacterization.java --- package org.junit.experimental.test.matchers; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.junit.Test; public class MatcherCharacterization { @Test public void findCamelCase() { Pattern pattern= Pattern.compile("([A-Z]?[a-z]*)"); String methodName= "hasAFreezer"; Matcher matcher= pattern.matcher(methodName); assertThat(matcher.find(), is(true)); } } --- NEW FILE: EachTest.java --- package org.junit.experimental.test.matchers; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import org.junit.Test; import org.junit.matchers.Each; public class EachTest { @Test public void eachDescription() { assertThat(Each.each(is("a")).toString(), is("each is \"a\"")); } } |
From: David S. <ds...@us...> - 2007-07-12 17:08:24
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/javamodel In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test/javamodel Removed Files: ConcreteFunctionTest.java FunctionTest.java Log Message: Re-organize theory packages --- ConcreteFunctionTest.java DELETED --- --- FunctionTest.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:23
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/matchers/api In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/matchers/api Removed Files: StringContains.java TypeSafeMatcher.java MethodNamedMatcher.java CamelCaseName.java IsCollectionContaining.java ClassNamedMatcher.java SubstringMatcher.java StackTrace.java Each.java Log Message: Re-organize theory packages --- StringContains.java DELETED --- --- TypeSafeMatcher.java DELETED --- --- MethodNamedMatcher.java DELETED --- --- CamelCaseName.java DELETED --- --- IsCollectionContaining.java DELETED --- --- ClassNamedMatcher.java DELETED --- --- SubstringMatcher.java DELETED --- --- StackTrace.java DELETED --- --- Each.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:23
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/theories/test/results In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/theories/test/results Removed Files: PrintableResultTest.java ResultMatchersTest.java Log Message: Re-organize theory packages --- PrintableResultTest.java DELETED --- --- ResultMatchersTest.java DELETED --- |
From: David S. <ds...@us...> - 2007-07-12 17:08:22
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/results In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26134/src/org/junit/experimental/test/results Added Files: PrintableResultTest.java ResultMatchersTest.java Log Message: Re-organize theory packages --- NEW FILE: PrintableResultTest.java --- package org.junit.experimental.test.results; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.allOf; import static org.junit.Assert.assertThat; import static org.junit.matchers.StringContains.containsString; import java.util.Arrays; import org.junit.experimental.results.PrintableResult; import org.junit.experimental.theories.methods.api.Theory; import org.junit.experimental.theories.runner.api.Theories; import org.junit.runner.Description; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; @RunWith(Theories.class) public class PrintableResultTest { @SuppressWarnings("unchecked") @Theory(nullsAccepted= false) public void backTraceHasGoodToString(String descriptionName, final String stackTraceClassName) { Failure failure= new Failure(Description .createSuiteDescription(descriptionName), new Throwable() { private static final long serialVersionUID= 1L; @Override public StackTraceElement[] getStackTrace() { return new StackTraceElement[] { new StackTraceElement( stackTraceClassName, "methodName", "fileName", 1) }; } }); assertThat(new PrintableResult(asList(failure)).toString(), allOf( containsString(descriptionName), containsString(stackTraceClassName))); } public static String SHELL_POINT= "Shell Point"; @Theory public void includeMultipleFailures(String secondExceptionName) { PrintableResult backtrace= new PrintableResult(Arrays.asList( new Failure(Description.createSuiteDescription("firstName"), new RuntimeException("firstException")), new Failure( Description.createSuiteDescription("secondName"), new RuntimeException(secondExceptionName)))); assertThat(backtrace.toString(), containsString(secondExceptionName)); } } --- NEW FILE: ResultMatchersTest.java --- package org.junit.experimental.test.results; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.junit.matchers.StringContains.containsString; import org.junit.Test; import org.junit.experimental.results.ResultMatchers; import org.junit.experimental.theories.methods.api.Theory; public class ResultMatchersTest { @Test public void hasFailuresHasGoodDescription() { assertThat(ResultMatchers.failureCountIs(3).toString(), is("has 3 failures")); } @Theory public void hasFailuresDescriptionReflectsInput(int i) { assertThat(ResultMatchers.failureCountIs(i).toString(), containsString("" + i)); } } |
From: David S. <ds...@us...> - 2007-07-12 17:08:04
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/runner In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25694/src/org/junit/experimental/test/runner Log Message: Directory /cvsroot/junit/junit/src/org/junit/experimental/test/runner added to the repository |
From: David S. <ds...@us...> - 2007-07-12 17:08:04
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25694/src/org/junit/experimental/test Log Message: Directory /cvsroot/junit/junit/src/org/junit/experimental/test added to the repository |
From: David S. <ds...@us...> - 2007-07-12 17:08:04
|
Update of /cvsroot/junit/junit/src/org/junit/matchers In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25694/src/org/junit/matchers Log Message: Directory /cvsroot/junit/junit/src/org/junit/matchers added to the repository |
From: David S. <ds...@us...> - 2007-07-12 17:08:04
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/matchers In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25694/src/org/junit/experimental/test/matchers Log Message: Directory /cvsroot/junit/junit/src/org/junit/experimental/test/matchers added to the repository |
From: David S. <ds...@us...> - 2007-07-12 17:08:04
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/assertion In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25694/src/org/junit/experimental/test/assertion Log Message: Directory /cvsroot/junit/junit/src/org/junit/experimental/test/assertion added to the repository |
From: David S. <ds...@us...> - 2007-07-12 17:08:03
|
Update of /cvsroot/junit/junit/src/org/junit/experimental/test/results In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25694/src/org/junit/experimental/test/results Log Message: Directory /cvsroot/junit/junit/src/org/junit/experimental/test/results added to the repository |