Skip to content
/ patere Public

Tiny library for building path of test resources based on package, class name and optionaly test method name

License

Notifications You must be signed in to change notification settings

lkrnac/patere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Patere

Tiny library for building path of test resources based on package, class name and optionally test method name. This can help keep test suite organized if it heavily uses some file resources. Developer can just drop resources belonging to the test into directory of certain structure and use Patere in test to build the test resources path.

It uses stack trace of current thread to build the path, therefore it's not suitable for production.

Uses Java 7.

Maven dependency

<dependency>
	<groupId>net.lkrnac.lib</groupId>
	<artifactId>patere</artifactId>
	<version>${version}</version>
	<scope>test</scope>
</dependency>

Find version in GitHub releases tab.

API

JavaDoc of current development branch

Examples

If stack trace is net.lkrnac.someapp.AppTest.testSomeMethod(), Patere builds following test resource paths:

String testResourcesPath = new Patere().getResourcesPathForMethod(); 
//testResourcesPath == "src/test/resources/net.lkrnac.someapp/AppTest/testSomeMethod/"

testResourcesPath = new Patere(false).getResourcesPathForMethod(); 
//testResourcesPath == "src/test/resources/net/lkrnac/someapp/AppTest/testSomeMethod/"

testResourcesPath = new Patere().getResourcesPathForClass(this.getClass.getName()); 
//testResourcesPath == "src/test/resources/net.lkrnac.someapp/AppTest/"

testResourcesPath = new Patere(false).getResourcesPathForClass(this.getClass.getName()); 
//testResourcesPath == "src/test/resources/net/lkrnac/someapp/AppTest/"

testResourcesPath = new Patere("test").getResourcesPathForClass(this.getClass.getName()); 
//testResourcesPath == "test/net/lkrnac/someapp/AppTest/"

##Development

About

Tiny library for building path of test resources based on package, class name and optionaly test method name

Resources

License

Stars

Watchers

Forks

Packages

No packages published