Giter Site home page Giter Site logo

arquillian-service-call-tracker-extension's Introduction

Maven Central Build Status codecov Codacy Badge Apache 2

service-call-tracker extension for JBoss Arquillian

This is the JBoss Arquillian extension for service-call-tracker.

Getting started

Add these maven artifacts to your project:

<dependency>
	<groupId>ch.abertschi.sct.arquillian</groupId>
	<artifactId>arquillian-service-call-tracker-extension-api</artifactId>
	<version>VERSION</version>
</dependency>
<dependency>
	<groupId>ch.abertschi.sct.arquillian</groupId>
	<artifactId>arquillian-service-call-tracker-extension-impl</artifactId>
	<version>VERSION</version>
</dependency>
  • service-call-tracker (ch.abertschi.sct:service-call-tracker-impl) is added to the Arquillian deployment programmatically and don't need to be set as a maven dependency.

What this extension does:

  • Configures service-call-tracker with information set in annotations placed on your Arquillian test methods
  • Packes service-call-tracker storage files to your Arquillian deployment

Use @RecordCall and @ReplayCall annotations on your Arquillian test methods to configure service-call-tracker. The configuration set with these annotations is accessable with SctConfigurator.getInstance().getConfiguration() and must be used to instanciate service-call-tracker.

@RunWith(Arquillian.class)
public class SampleArquilianTest
{
    @Inject
    MyService service;

    @Deployment
    public static Archive<?> deploy()
    {
        return ShrinkWrap.create(JavaArchive.class)
                .addClass(...)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Test
    @RecordCall("recordings.xml") // creates file recordings.xml with recorded calls
    public void test_around_aspect()
    {
       	// your test
    }
    
    @Test
    @ReplayCall("calls.xml") // replays calls stored in calls.xml located in current directory
    public void test_around_aspect()
    {
	// your test
    }
}
// Create service-call-tracker
Configuration config = SctConfigurator.getInstance().getConfiguration(); // set by this Arquillian extension
ServiceCallTracker serviceCallTracker = new ServiceCallTracker(config);

Arquillian.xml

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://jboss.org/schema/arquillian"
           xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

   <engine>
       <property name="deploymentExportPath">target/deployments</property>
   </engine>

   <extension qualifier="serviceCallTracker">
       <property name="recordingEnabled">true</property>
       <property name="replayingEnabled">true</property>

       <property name="throwExceptionOnNotFound">true</property>
       <property name="throwExceptionOnIncompatibleReturnType">true</property>

       <property name="sourceDirectory">./src/test/java</property>
       <property name="recordingStorageDirectory">./src/test/resources</property>
       <property name="replayingStorageDirectory">./src/test/resources</property>

   </extension>
</arquillian>
  • recordingEnabled:

  • default: true

  • Enable the recording feature (activated with @RecordCall in code)

  • replayingEnabled:

  • default: true

  • Enable the replaying feature (activated with @ReplayCall in code)

  • throwExceptionOnNotFound:

  • default: true

  • Throw exception if replaying mode is activated but no matching call was found in storage file

  • throwExceptionOnIncompatibleReturnType:

  • default: true

  • Throw exception if return type of intercepted method does not match with stored response. If set to false, service-call-tracker will execute method implementation instead.

  • sourceDirectory:

  • default: `./src/main/java'

  • The root directory of your test soure code.

  • recordingStorageDirectory:

  • default: `./'

  • The root directory to look for recording storage files. Storage files are first searched in the directory of your test class and then at this location.

  • replayingStorageDirectory:

  • default: `./'

  • The root directory to look for replaying storage files. Storage files are first searched in the directory of your test class and then at this location.

Big-Picture

big picture

arquillian-service-call-tracker-extension's People

Contributors

abertschi avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

arquillian-service-call-tracker-extension's Issues

Make API annotations great again

The currently used annotations SctInterceptTo|By are not very self-explanatory which is why we should brainstorm some better names.

Record calls

@RecordCalls
@MockCalls
@RecordCallsToStorage 
@DumpCallsToStorage

Load calls

@CallStorage
@UseCallStorage
@LoadCalls
  • Allow annotations to be placed at class level and method lvl
  • Support a value field to set storage location

Storage location

Search priority:

    1. current source directory
    1. default storage directory

If storage location is not set, the storage file is searched in current directory with the name of the test method (i.e. ./my_test_method.xml) or class name if annotation is placed at class level (i.e. MyClass.xml). If non of these files are found, change directory to the default storage directory and search there by method name or class name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.