Skip to content

Commit

Permalink
Patched javadoc, thanks to Matthias Schmidt
Browse files Browse the repository at this point in the history
RunWith is @inherited
Added acknowledgements
to-do is up to date
  • Loading branch information
dsaff committed Mar 10, 2006
1 parent 23ab517 commit 65d6b62
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 56 deletions.
2 changes: 2 additions & 0 deletions acknowledgements.txt
@@ -0,0 +1,2 @@
2006 March 9
Matthias Schmidt: improved org.junit package javadoc
2 changes: 1 addition & 1 deletion build.xml
@@ -1,6 +1,6 @@
<project name="junit" default="dist" basedir=".">
<property file="${user.home}/.junit.properties" />
<property name="version" value="4.0" />
<property name="version" value="4.1" />
<property name="dist" value="junit${version}" />
<property name="versionfile" value="junit/runner/Version.java" />
<property name="zipfile" value="${dist}.zip" />
Expand Down
9 changes: 8 additions & 1 deletion done.txt
Expand Up @@ -39,5 +39,12 @@
* make sure TestListener is symmetric and meets needs of runner developers
* TestRunEvent
* Decide how we ship JUnit-- 1.5 only or hybrid

* README.html
* add javadoc to API interfaces and Annotations
http://java.sun.com/j2se/javadoc/writingapispecs/index.html
* Merge branch back into head
* review Ant scripts
* make suites simpler for both the IDE providers and the users
* ClassRequest should search up the hierarchy for the requested Class to look for @RunWith


2 changes: 1 addition & 1 deletion junit/runner/Version.java
Expand Up @@ -9,7 +9,7 @@ private Version() {
}

public static String id() {
return "4.0";
return "4.1";
}

public static void main(String[] args) {
Expand Down
7 changes: 4 additions & 3 deletions org/junit/After.java
Expand Up @@ -6,10 +6,10 @@
import java.lang.annotation.Target;

/**
* If you allocate external resources in a <code>@Before</code> method you need to release them
* If you allocate external resources in a {@link org.junit.Before} method you need to release them
* after the test runs. Annotating a <code>public void</code> method
* with <code>@After</code> causes that method to be run after the <code>@Test</code> method. All <code>@After</code>
* methods are guaranteed to run even if a <code>@Before</code> or <code>@Test</code> method throws an
* with <code>@After</code> causes that method to be run after the {@link org.junit.Test} method. All <code>@After</code>
* methods are guaranteed to run even if a {@link org.junit.Before} or {@link org.junit.Test} method throws an
* exception. The <code>@After</code> methods declared in superclasses will be run after those of the current
* class.
* <p>
Expand All @@ -30,6 +30,7 @@
* </code>
*
* @see org.junit.Before
* @see org.junit.Test
*/

@Retention(RetentionPolicy.RUNTIME)
Expand Down
5 changes: 3 additions & 2 deletions org/junit/AfterClass.java
Expand Up @@ -6,10 +6,10 @@
import java.lang.annotation.Target;

/**
* If you allocate expensive external resources in a <code>@BeforeClass</code> method you need to release them
* If you allocate expensive external resources in a {@link org.junit.BeforeClass} method you need to release them
* after all the tests in the class have run. Annotating a <code>public static void</code> method
* with <code>@AfterClass</code> causes that method to be run after all the tests in the class have been run. All <code>@AfterClass</code>
* methods are guaranteed to run even if a <code>@BeforeClass</code> method throws an
* methods are guaranteed to run even if a {@link org.junit.BeforeClass} method throws an
* exception. The <code>@AfterClass</code> methods declared in superclasses will be run after those of the current
* class.
* <p>
Expand All @@ -33,6 +33,7 @@
* </code>
*
* @see org.junit.BeforeClass
* @see org.junit.Test
*/

@Retention(RetentionPolicy.RUNTIME)
Expand Down
115 changes: 85 additions & 30 deletions org/junit/Assert.java
Expand Up @@ -9,18 +9,23 @@
* ...<br>
* &nbsp;&nbsp;assertEquals(...);<br>
* </code>
*
* @see java.lang.AssertionError
*/

public class Assert {
/**
* Protect constructor since it is a static only class
*/
protected Assert() {
}

// TODO: param comments should start with lower case letters

/**
* Asserts that a condition is true. If it isn't it throws an
* AssertionError with the given message.
* {@link AssertionError} with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param condition condition to be checked
*/
static public void assertTrue(String message, boolean condition) {
if (!condition)
Expand All @@ -29,30 +34,36 @@ static public void assertTrue(String message, boolean condition) {

/**
* Asserts that a condition is true. If it isn't it throws an
* AssertionError.
* {@link AssertionError} without a message.
* @param condition condition to be checked
*/
static public void assertTrue(boolean condition) {
assertTrue(null, condition);
}

/**
* Asserts that a condition is false. If it isn't it throws an
* AssertionError with the given message.
* {@link AssertionError} with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param condition condition to be checked
*/
static public void assertFalse(String message, boolean condition) {
assertTrue(message, !condition);
}

/**
* Asserts that a condition is false. If it isn't it throws an
* AssertionError.
* {@link AssertionError} without a message.
* @param condition condition to be checked
*/
static public void assertFalse(boolean condition) {
assertFalse(null, condition);
}

/**
* Fails a test with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @see AssertionError
*/
static public void fail(String message) {
throw new AssertionError(message);
Expand All @@ -67,7 +78,10 @@ static public void fail() {

/**
* Asserts that two objects are equal. If they are not, an
* AssertionError is thrown with the given message.
* {@link AssertionError} is thrown with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param expected expected value
* @param actual actual value
*/
static public void assertEquals(String message, Object expected, Object actual) {
if (expected == null && actual == null)
Expand All @@ -82,15 +96,20 @@ static public void assertEquals(String message, Object expected, Object actual)

/**
* Asserts that two objects are equal. If they are not, an
* AssertionError is thrown.
* {@link AssertionError} without a message is thrown.
* @param expected expected value
* @param actual the value to check against <code>expected</code>
*/
static public void assertEquals(Object expected, Object actual) {
assertEquals(null, expected, actual);
}

/**
* Asserts that two object arrays are equal. If they are not, an
* AssertionError is thrown with the given message.
* {@link AssertionError} is thrown with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param expecteds Object array or array of arrays (multi-dimensional array) with expected values
* @param actuals Object array or array of arrays (multi-dimensional array) with actual values
*/
public static void assertEquals(String message, Object[] expecteds, Object[] actuals) {
if (expecteds == actuals)
Expand All @@ -117,18 +136,25 @@ public static void assertEquals(String message, Object[] expecteds, Object[] act

/**
* Asserts that two object arrays are equal. If they are not, an
* AssertionError is thrown.
* {@link AssertionError} is thrown.
* @param expecteds Object array or array of arrays (multi-dimensional array) with expected values
* @param actuals Object array or array of arrays (multi-dimensional array) with actual values
*/
public static void assertEquals(Object[] expecteds, Object[] actuals) {
assertEquals(null, expecteds, actuals);
}

/**
* Asserts that two doubles are equal to within a positive delta. If they
* are not, an AssertionError is thrown with the given message. If the
* are not, an {@link AssertionError} is thrown with the given message. If the
* expected value is infinity then the delta value is ignored. NaNs are
* considered equal:
* assertEquals(Double.NaN, Double.NaN, *) passes
* <code>assertEquals(Double.NaN, Double.NaN, *)</code> passes
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param expected expected value
* @param actual the value to check against <code>expected</code>
* @param delta the maximum delta between <code>expected</code> and <code>actual</code> for which
* both numbers are still considered equal.
*/
static public void assertEquals(String message, double expected, double actual, double delta) {
if (Double.compare(expected, actual) == 0)
Expand All @@ -139,21 +165,30 @@ static public void assertEquals(String message, double expected, double actual,

/**
* Asserts that two doubles are equal to within a positive delta. If they
* are not, an AssertionError is thrown. If the
* are not, an {@link AssertionError} is thrown. If the
* expected value is infinity then the delta value is ignored.NaNs are
* considered equal:
* assertEquals(Double.NaN, Double.NaN, *) passes
* <code>assertEquals(Double.NaN, Double.NaN, *)</code> passes
* @param expected expected value
* @param actual the value to check against <code>expected</code>
* @param delta the maximum delta between <code>expected</code> and <code>actual</code> for which
* both numbers are still considered equal.
*/
static public void assertEquals(double expected, double actual, double delta) {
assertEquals(null, expected, actual, delta);
}

/**
* Asserts that two floats are equal to within a positive delta. If they
* are not, an AssertionError is thrown with the given message. If the
* are not, an {@link AssertionError} is thrown with the given message. If the
* expected value is infinity then the delta value is ignored.NaNs are
* considered equal:
* assertEquals(Float.NaN, Float.NaN, *) passes
* <code>assertEquals(Float.NaN, Float.NaN, *)</code> passes
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param expected the expected float value
* @param actual the float value to check against <code>expected</code>
* @param delta the maximum delta between <code>expected</code> and <code>actual</code> for which
* both numbers are still considered equal.
*/
static public void assertEquals(String message, float expected, float actual, float delta) {
if (Float.compare(expected, actual) == 0)
Expand All @@ -164,50 +199,63 @@ static public void assertEquals(String message, float expected, float actual, fl

/**
* Asserts that two floats are equal to within a positive delta. If they
* are not, an AssertionError is thrown. If the
* expected value is infinity then the delta value is ignored.NaNs are
* are not, an {@link AssertionError} is thrown. If the
* expected value is infinity then the delta value is ignored. {@link Float#NaN NaNs} are
* considered equal:
* assertEquals(Float.NaN, Float.NaN, *) passes
* <code>assertEquals(Float.NaN, Float.NaN, *)</code> passes
* @param expected the expected value
* @param actual the value to check against <code>expected</code>
* @param delta the maximum delta between <code>expected</code> and <code>actual</code> for which
* both numbers are still considered equal.
*/
static public void assertEquals(float expected, float actual, float delta) {
assertEquals(null, expected, actual, delta);
}

/**
* Asserts that an object isn't null. If it is an AssertionError is
* Asserts that an object isn't null. If it is an {@link AssertionError} is
* thrown with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param object Object to check or <code>null</code>
*/
static public void assertNotNull(String message, Object object) {
assertTrue(message, object != null);
}

/**
* Asserts that an object isn't null. If it is an AssertionError is
* Asserts that an object isn't null. If it is an {@link AssertionError} is
* thrown.
* @param object Object to check or <code>null</code>
*/
static public void assertNotNull(Object object) {
assertNotNull(null, object);
}

/**
* Asserts that an object is null. If it is not, an AssertionError is
* Asserts that an object is null. If it is not, an {@link AssertionError} is
* thrown with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param object Object to check or <code>null</code>
*/
static public void assertNull(String message, Object object) {
assertTrue(message, object == null);
}

/**
* Asserts that an object is null. If it isn't an AssertionError is
* Asserts that an object is null. If it isn't an {@link AssertionError} is
* thrown.
* @param object Object to check or <code>null</code>
*/
static public void assertNull(Object object) {
assertNull(null, object);
}

/**
* Asserts that two objects refer to the same object. If they are not, an
* AssertionError is thrown with the given message.
* {@link AssertionError} is thrown with the given message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param expected the expected object
* @param actual the object to compare to <code>expected</code>
*/
static public void assertSame(String message, Object expected, Object actual) {
if (expected == actual)
Expand All @@ -217,28 +265,35 @@ static public void assertSame(String message, Object expected, Object actual) {

/**
* Asserts that two objects refer to the same object. If they are not the
* same, an AssertionError is thrown.
* same, an {@link AssertionError} without a message is thrown.
* @param expected the expected object
* @param actual the object to compare to <code>expected</code>
*/
static public void assertSame(Object expected, Object actual) {
assertSame(null, expected, actual);
}

/**
* Asserts that two objects do not refer to the same object. If they do
* refer to the same object, an AssertionError is thrown with the given
* refer to the same object, an {@link AssertionError} is thrown with the given
* message.
* @param message the identifying message or <code>null</code> for the {@link AssertionError}
* @param unexpected the object you don't expect
* @param actual the object to compare to <code>unexpected</code>
*/
static public void assertNotSame(String message, Object expected, Object actual) {
if (expected == actual)
static public void assertNotSame(String message, Object unexpected, Object actual) {
if (unexpected == actual)
failSame(message);
}

/**
* Asserts that two objects do not refer to the same object. If they do
* refer to the same object, an AssertionError is thrown.
* refer to the same object, an {@link AssertionError} without a message is thrown.
* @param unexpected the object you don't expect
* @param actual the object to compare to <code>unexpected</code>
*/
static public void assertNotSame(Object expected, Object actual) {
assertNotSame(null, expected, actual);
static public void assertNotSame(Object unexpected, Object actual) {
assertNotSame(null, unexpected, actual);
}

static private void failSame(String message) {
Expand Down
2 changes: 1 addition & 1 deletion org/junit/Before.java
Expand Up @@ -8,7 +8,7 @@
/**
* When writing tests, it is common to find that several tests need similar
* objects created before they can run. Annotating a <code>public void</code> method
* with <code>@Before</code> causes that method to be run before the <code>@Test</code> method.
* with <code>@Before</code> causes that method to be run before the {@link org.junit.Test} method.
* The <code>@Before</code> methods of superclasses will be run before those of the current class.
* <p>
* Here is a simple example:
Expand Down
6 changes: 3 additions & 3 deletions org/junit/ComparisonFailure.java
@@ -1,7 +1,7 @@
package org.junit;

/**
* Thrown when an assertEquals(String, String) fails. Create and throw
* Thrown when an {@link org.junit.Assert#assertEquals(Object, Object) assertEquals(String, String)} fails. Create and throw
* a <code>ComparisonFailure</code> manually if you want to show users the difference between two complex
* strings.
*
Expand Down Expand Up @@ -38,14 +38,14 @@ public String getMessage() {
}

/**
* Returns the actual value
* Returns the actual string value
* @return the actual string value
*/
public String getActual() {
return fActual;
}
/**
* Returns the expected value
* Returns the expected string value
* @return the expected string value
*/
public String getExpected() {
Expand Down

0 comments on commit 65d6b62

Please sign in to comment.