Skip to content

Future support for Vertx.x JUnit tests

License

Notifications You must be signed in to change notification settings

gofabian/vertx-unit-future

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vertx-unit-future

Future support for Vertx.x JUnit tests.

https://jitpack.io/#gofabian/vertx-unit-future

Release

Installation

To use it in your Maven build add:

  <repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
  </repositories>

and the dependency:

	<dependency>
		<groupId>com.github.gofabian</groupId>
		<artifactId>vertx-unit-future</artifactId>
		<version>x.x.x</version>
	</dependency>

Getting started

The FutureVertxRunner adds Future support to the VertxUnitRunner.

Syntax:

  • Parameters: TestContext or none
  • Return type: Future or void
  • Supported methods: @Test, @Before, @After, @BeforeClass, @AfterClass
    @RunWith(FutureVertxRunner.class)
    public class MyTest {
        
        @BeforeClass
        public static Future setUpClass() {
            return Future.succeededFuture();
        }
    
        @Before
        public Future setUp() {
            return Future.succeededFuture();
        }
    
        @Test
        public Future testFutureResult(TestContext context) {
            return Future.succeededFuture();
        }
        
        @After
        public Future tearDown() {
            return Future.succeededFuture();
        }
    
        @AfterClass
        public static Future tearDownClass() {
            return Future.succeededFuture();
        }       

    }

Examples

Success:

    @Test
    public Future testSuccess() {
        return Future.succeededFuture();
    }

Failure:

    @Test
    public Future testFailure() {
        return Future.failedFuture("error");
    }

Incomplete (timeout):

    @Test
    public static Future testTimeout() {
        return Future.future(); // incomplete future
    }

Returning null will behave like a void return type:

    @Test
    public Future testNormal() {
        return null; // success
    }

About

Future support for Vertx.x JUnit tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages