TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    JBehave/ JUnit

    JUnit @RunWith Annotation

    Introduction

    In this post, we will discuss @RunWith Annotation. When a class is annotated with @RunWith or extends a class annotated with it, JUnit will invoke the class that it references to run the tests in that class instead of the runner built with JUnit.

    What is a Runner?

    A Runner runs tests and notifies a RunNotifier of significant events as it does so. We can also use custom runners if we want by extending the Runner class. When creating a custom runner, in addition to implementing the abstract methods you must also provide a constructor that takes as an argument the Class containing the tests. For example, Eclipse has a built-in a graphical runner.

    In order to use @RunWith annotation, we need to pass a class that is extended from Runner.

    Class<? extends Runner>

     

     

    Test_Runner

     

    We can run JBehave stories using this annotation. For example, we can use AnnotatedEmbedderRunner with this annotation.

    @RunWith(value=AnnotatedEmbedderRunner.class) 
    @UsingEmbedder(embedder=Embedder.class)

     

    AnnotatedEmbedderRunner is a JUnit Runner that uses the AnnotationBuilder to create an embeddable test instance.

    Another example we can run JBehave stories using Serenity by extending from SerenityStories class.

    SerentiyStories class uses SerenityReportingRunner

    @RunWith(SerenityReportingRunner.class)

    SerenityStories is a JUnit-runnable test case designed to run a set of JBehave stories in a given package.

    Related Posts

    Create a New Project Eclipse

    JBehave /

    Cucumber Java BDD Selenium Framework

    Getting Started with JUnit Framework

    JUnit /

    Getting Started with JUnit Framework

    JBehave + Serenity Sample Project

    JBehave /

    JBehave + Serenity Sample Project

    Run JUnit tests from command line

    JUnit /

    Run JUnit tests from command line

    Serenity BDD Automation Framework

    JBehave /

    Serenity BDD Automation Framework

    ‹ JUnit Test Execution Order Example› Create JUnit Test Suite in Eclipse

    Recent Posts

    • ChatGPT Plans Free and PlusChatGPT Subscription Plans
    • Stellar Converter for Database ToolStellar Converter for Database
    • Stellar MySQL Log AnalyzerStellar Log Analyzer for MySQL
    • Stellar Repair for MySQLStellar Repair for MySQL
    • ChatGPT IntroductionChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI FeaturesChatGPT4 Conversational AI Features
    • Trends in Software EngineeringShaping the Future of Development: Exploring Key Trends in Software Engineering
    • Java PerformanceImproving Java Performance with Multithreading
    • QDrant Vector DatabaseOpen-source Vector Databases
    • Difference between PHP and JavaScript?
    • Bing AI Browser Web ContentBing Conversation Styles
    • ChatGPT PreviewChatGPT Introduction
    • Open Source AI Frameworks TensorFlowOpen Source AI Frameworks
    • Artificial Intelligence Tools

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com