Skip to content

Tasktop/koans-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JUnit koans-runner

Build Status Maven Status License

A JUnit extension to learn through unit tests. Inspired by the famous Ruby Koans this project provides generic JUnit runners to write koans in Java.

What are Koans?

Koans are just unit tests! A Koan Suite is a set of failing test classes that explain a certain technology or framework to the user. The task for the user is to get all tests green and "reach enlightment". To achieve this the koans-runner provides continuous feedback and reproducible test execution.

koans

Installation

Download the koans-runner from Maven Central or add the dependency to your pom.

<dependency>
	<groupId>com.tasktop.koans</groupId>
	<artifactId>koans-runner</artifactId>
</dependency>

Usage

To create your own Koans you need to provide two things:

  1. One or more Test classes. They need to use @RunWith( KoanRunner.class ) to be executed in the same order as the methods are defined in the source code.
@RunWith( KoanRunner.class )
public class MyTest {
	
	@Test
	public void easyFirstTest() {
		fail(); // remove this line to make the test green
	}
	
	@Test
	public void notSoEasySecondTest() {
		assertTrue(false); // figure out how to pass the assertion
	}

}
  1. One Suite class that defines the Test classes in the order to execute. This suite needs to use the @RunWith( KoanSuiteRunner.class ) to produce the zen like output.
@RunWith( KoanSuiteRunner.class )
@SuiteClasses( {
	MyTest.class
})
public class MySuite {}

Enable ansi colors

To enable the ansi colors like in the screenshot above you need to add the -Denable.ansi=true property when launching your test suite. To get these nice ansi colors within Eclipse you can install the nice ansi-econsole.

License

All code in this repository is published under terms of the Apache 2.0 Software License.

About

JUnit Extension to learn through unit tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages