Skip to content
BDD and TDD testing framework for Guice
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Latest release: 1.0.0
License: Apache 2.0


Guice-Behave is a test framework for Google Guice applications, created to help writing tests that follow TDD and BDD methodologies. The main idea of the framework is using the language to auto-describe the test avoiding to use other tools or sources.

How to get it

You can get Guice Behave as a maven dependency.


How it works

Create a Junit 4 test and add RunWith annotation with TestRunner class and the Modules annotation.

@RunWith(TestRunner.class) @Modules(MyModule.class)
public class MyTest {
  @Inject private MyClass myClass;

  public void testWithGuice() {
    assertNotNull("Guice should works!", myClass);

The test runs in the Guice context defined into MyModule class.

public MyModule extends AbstractModule {
  protected void configure() {

For more details refer to the TestRunner page.

Tell a story

Guice-Behave helps your tests to tell a story. Each part of the story comes from the names methods running during the tests. For example this test...

@RunWith(StoryRunner.class) @Modules(MyModule.class)
public void NelsonMandelaTest {
  public void FamousSpeech{
    i_have_cherished_the_ideal_of_a_$1_society("democratic", "free");

  void i_have_cherished_the_ideal_of_a_$1_society(String typesOfSociety) { ... }

  void in_which_all_persons_live_together_in_harmony() { ... }

  void and_with_equal_opportunities() { ... }


... is translated in this ref ...

  Story "Famous speech"
  by NelsonMandelaTest
I have cherished the ideal of a democratic and free society
In which all persons live together in harmony
And with equal opportunities

This translation helps to write and organize high-level behavioral tests with no effort, using what the language offers and encouraging the re-usability of the tests. For more details about refer to the StoryRunner page.

You can’t perform that action at this time.