Giter Club home page Giter Club logo

jast's Introduction

image

Jast

Maven Central FOSSA Status CodeFactor


<depedencies>
    <dependency>
        <groupId>me.mrxbox98.jast</groupId>
        <artifactId>jast</artifactId>
        <version>2.1.2</version>
    </dependency>
</depedencies>

A fast testing utility for Java based off of Jest for Javascript

import me.mrxbox98.jast.core.JastTestTests;

public class Test {
    public static void main(String[] args) {
        //Creates a new test
        JastTest jastTest = new JastTest();
        //Use reflection to get the method to test
        jastTest.setMethod(Test.class.getMethod("getString"));
        //Unlimited number of expected values
        jastTest.setExpected("tet","test");
        //Name of the test
        jastTest.setName("TestName");
        //Description of the test
        jastTest.setDescription("TestDescription");
        //The time the test should take in milliseconds
        jastTest.setTime(50);
        //Tests the method. Add a boolean param to determine if the results should be printed out
        jastTest.test();
    }

    public static String getString() {
        return "test";
    }
}

image

Chaining

Jast supports chaining so you can write an entire test in one line.

import me.mrxbox98.jast.core.JastTestTests;

public class Test {
    public static void main(String[] args) {
        //Creates a new test and sets both the method and expected values in one line
        JastTest jastTest = new JastTest().jastTest.setMethod(Test.class.getMethod("getString")).setExpected("tet","test");
    }

    public static String getString() {
        return "test";
    }
}

Mass Testing

You call add multiple tests to a mass test in order to tests multiple methods at a time.

import me.mrxbox98.jast.core.JastTestTests;
import me.mrxbox98.jast.core.MassTest;

public class Test {

    public static void main(String[] args)
    {
        try {
            MassTest byteMassTest = new MassTest();

            JastTest byteTest1 = new JastTest();
            byteTest1.setMethod(Test.class.getMethod("byteTest1"));
            byteTest1.setExpected((byte) 1);
            byteMassTest.add(byteTest1);

            JastTest byteTest2 = new JastTest();
            byteTest2.setMethod(Test.class.getMethod("byteTest2"));
            byteTest2.setExpected((byte) 2);
            byteMassTest.add(byteTest2);

            JastTest byteTest3 = new JastTest();
            byteTest3.setMethod(Test.class.getMethod("byteTest3"));
            byteTest3.setExpected();
            byteMassTest.add(byteTest3);



            byteMassTest.test(true);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    public static Byte byteTest1()
    {
        return 1;
    }

    public static Byte byteTest2()
    {
        return 2;
    }

    public static Byte byteTest3()
    {
        return null;
    }

}

image

Error Testing

import me.mrxbox98.jast.core.JastTestTests;
import me.mrxbox98.jast.core.MassTest;

public class ByteTest {
    public static void main(String[] args)
    {
        try {
            MassTest byteMassTest = new MassTest();

            JastTest byteTest1 = new JastTest();
            byteTest1.setMethod(ByteTest.class.getMethod("byteTest1"));
            byteTest1.setExpected((byte) 1);
            byteMassTest.add(byteTest1);

            JastTest byteTest2 = new JastTest();
            byteTest2.setMethod(ByteTest.class.getMethod("byteTest2"));
            byteTest2.setExpected((byte) 2);
            byteMassTest.add(byteTest2);

            JastTest byteTest3 = new JastTest();
            byteTest3.setMethod(ByteTest.class.getMethod("byteTest3"));
            byteTest3.setExpected();
            byteMassTest.add(byteTest3);

            JastTest byteTest4 = new JastTest();
            byteTest4.setMethod(ByteTest.class.getMethod("byteTest4"));
            byteTest4.setExpected(new ArrayIndexOutOfBoundsException());
            byteMassTest.add(byteTest4);

            JastTest byteTest5 = new JastTest();
            byteTest5.setMethod(ByteTest.class.getMethod("byteTest5"));
            byteTest5.setExpected(new IllegalArgumentException());
            byteMassTest.add(byteTest5);

            byteMassTest.test(true);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
    }

    public static Byte byteTest1()
    {
        return 1;
    }

    public static Byte byteTest2()
    {
        return 2;
    }

    public static Byte byteTest3()
    {
        return null;
    }

    public static Byte byteTest4()
    {
        throw new ArrayIndexOutOfBoundsException();
    }

    public static Byte byteTest5()
    {
        throw new IllegalArgumentException();
    }

}

image

License

FOSSA Status

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.