title: How beforeScenario and afterScenario works in JBehave
body: <p>Can someone show examples of how beforeScenario and afterScenario works in JBehave?</p>
  
  <p>I created a class with two methods gearUp with <strong>@BeforeScenario</strong> and tearDown with <strong>@AfterScenario</strong> annotations.</p>
  
  <p>But these methods are never invoked in JBehave.</p>
  
  <p>What extra configurations are needed. Any code examples will help us.</p>
  
  <p>Whereas this simple and neat in Cucumber.</p>
  
  <p>Following is my story file with single step(src/test/resources/storeis):</p>
  
  <pre><code>Scenario:  SampleTest
  
  Given I am test
  </code></pre>
  
  <p>Following is my Steps file</p>
  
  <pre class="lang-java prettyprint-override"><code>public class jbehavetc {
  
      @Given("I am test")
      public void startOnUrl(String url) {
         System.out.println("I am actual test");
      }
  }
  </code></pre>
  
  <p>Following is my Hooks file which contains BeforeScenario and AfterScenario methods</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Hooks {
  
      @BeforeScenario
      public void startSystem() throws Exception {
         System.out.println("I am before scenario");
      }
  
      @AfterScenario
      public void stopSystem() throws Exception {
         System.out.println("I am after scenario");
      }
  
  }
  </code></pre>
  
  <p>To run the above story i created a runner file and wanted to run as JUnit Test(<strong>Correct me this is not the right approach</strong>)</p>
  
  <pre class="lang-java prettyprint-override"><code>public class JBehaveRunner extends JUnitStory{
  
  
      @Override
      public Configuration configuration() {
          return new MostUsefulConfiguration()
              .useStoryLoader(
                  new LoadFromClasspath(getClass().getClassLoader()))
              .useStoryReporterBuilder(   
                  new StoryReporterBuilder()
                      .withDefaultFormats()
                      .withFormats(Format.HTML));
      }
  
      @Override
      public InjectableStepsFactory stepsFactory() {
          return new InstanceStepsFactory(configuration(), new jbehavetc(), 
              new Hooks());
      }
  
      public List&lt;String&gt; storyPaths() {
          return new StoryFinder().findPaths(
              CodeLocations.codeLocationFromClass(this.getClass()),
              Arrays.asList("**/*.story"),
              Arrays.asList(""));
      }
  
      @Test
      public void run() throws Throwable {
          super.run();
      }
  }
  </code></pre>
  
  <p>When i run above runner as JUnit test, nothing is getting executed. How can i run above story? I want Before and After Scenario methods needs to be invoked when i run this runner or story file.</p>