diff --git a/wpilibj/wpilibJava/pom.xml b/wpilibj/wpilibJava/pom.xml index 383cb772ac..e6f61ae28e 100644 --- a/wpilibj/wpilibJava/pom.xml +++ b/wpilibj/wpilibJava/pom.xml @@ -67,6 +67,11 @@ NetworkTables 0.1.0-SNAPSHOT + + junit + junit + 4.11 + diff --git a/wpilibj/wpilibJava/src/test/java/edu/wpi/first/wpillibj/ExampleTest.java b/wpilibj/wpilibJava/src/test/java/edu/wpi/first/wpillibj/ExampleTest.java new file mode 100644 index 0000000000..42901580c0 --- /dev/null +++ b/wpilibj/wpilibJava/src/test/java/edu/wpi/first/wpillibj/ExampleTest.java @@ -0,0 +1,46 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008-2012. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package edu.wpi.first.wpilibj; + +import static org.junit.Assert.*; +import org.junit.Test; + +/** + * All test classes should be well-documented as to what you are testing. Any + * mocks that you create should be put in the same package as the class you are + * mocking. Unit tests MUST not depend on any specific hardware platform, so any + * dependencies must be mocked out. + * + * + * Tests are written in with standard JUnit syntax, and are executed with Junit + * 4. Tests should be named the same as the unit under test, with "Test" + * appended. So a test on the Jaguar class would be called JaguarTest. + * + * @author Fredric Silberberg + */ +public class ExampleTest { + + /** + * Individual tests should be documented, and naming should be + * "name of thing (unit/function) being tested" + "Test". So a test ensuring + * that an input called "motor" is null-checked correctly would be called + * motorNullCheckTest. + */ + @Test + public void additionTest() { + assertEquals(2 + 2, 4); + } + + /** + * Tests that expect exceptions should use standard junit expected syntax + */ + @Test(expected = Exception.class) + public void exceptionTest() throws Exception { + throw new Exception("This is expected"); + } +} \ No newline at end of file