org.sonar.test
Class TestUtils

java.lang.Object
  extended by org.sonar.test.TestUtils

public final class TestUtils
extends Object

Utilities for unit tests

Since:
2.2

Method Summary
static void assertPrivateConstructor(Class clazz)
           
static File getResource(Class baseClass, String path)
          Search for a resource in the classpath.
static File getResource(String path)
          Search for a test resource in the classpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResource

public static File getResource(String path)
Search for a test resource in the classpath. For example getResource("org/sonar/MyClass/foo.txt");

Parameters:
path - the starting slash is optional
Returns:
the resource. Null if resource not found

getResource

public static File getResource(Class baseClass,
                               String path)
Search for a resource in the classpath. For example calling the method getResource(getClass(), "myTestName/foo.txt") from the class org.sonar.Foo loads the file $basedir/src/test/resources/org/sonar/Foo/myTestName/foo.txt

Returns:
the resource. Null if resource not found

assertPrivateConstructor

public static void assertPrivateConstructor(Class clazz)


Copyright © 2009–2014 SonarSource. All rights reserved.