Skip to content
A testing utilities library
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis.yml
README.md
pom.xml

README.md

Build Status Dependency Status Coverage Status Maven Central Javadocs

Synopsis

This project support for:

  • testing private, protected, package access and public method
  • testing script performance

Code Example

1. Get method by name

	// with no arguments
	Method nothing = ReflectMethodUtil.getMethod("nothing", ClassA.class);
	// with one argument (Integer)
	Method add = ReflectMethodUtil.getMethod("add", ClassA.class, Integer.class);

2. Invoke method

	// invoke method
	Object result = ReflectMethodUtil.invokeMethod(add, new ClassA(), new Integer(1));
	//invoke method by name
	Object result = ReflectMethodUtil.invokeMethod("add", new ClassA(), new Integer(1));
	// invoke static method by name
	ReflectMethodUtil.invokeStaticMethod("hello", ClassA.class, "tvd12.com");
	// use builder sytax
	Integer result = MethodInvoker.create()
                .method("add")
                .param(new Integer(1))
                .object(new ClassA())
                .invoke(Integer.class);

3. Test script performance

  • With java 7
	long time = Performance.create()
            .loop(1000000000) // optional, default 1000000
            .test(new Script() {
                @Override
                public void execute() {
                	System.out.println("Hello World");
                }
            })
            .getTime();
  • With java 8
	long time = Performance.create()
            .loop(1000000000) // optional, default 1000000
            .test(() -> {System.out.println("Hello World");})
            .getTime();

Motivation

Because sometimes we want to call private, protected, package access and public method, we need test performance to our script and export result to file so, we need create a library to support them

Installation

	<dependency>
		<groupId>com.tvd12</groupId>
		<artifactId>test-util</artifactId>
		<version>1.0.5</version>
	</dependency>

API Reference

http://www.javadoc.io/doc/com.tvd12/test-util

Tests

mvn test

Contributors

None

License

  • Apache License, Version 2.0
You can’t perform that action at this time.