Menu

Home

chinple

MTest is model based testing framework. It supports Python, Java, C++ now.
Currently the Java version is opened. The main function list as follows:
1. Object Assertions, it can be used to validate complicate object.
2. JSON Assertions, validating Strings by converting Strings to JSON object and then validating the JSON object.
3. Test logger and reporting.
4. Test configuration.
5. Mode based testing support: generating test data by multiple strategies and supporting data-driven testing, such as reading test data from CSV file, JSON file or JSON string
6. Filter executing test cases by case name register priority and test type.
7. Compact JUnit and TestNG, it means you can use all above functions in JUnit and TestNG test framework.
8. Easy to extends the test framework to help upgrade the original test framework to MTest.

Code example:
1. Get the sample in http://sourceforge.net/p/mtest-sf/code/ci/2307280ee4a4902d36a2324927f83a5f23d04f1c/tree/Java/build/
Help doc: https://sourceforge.net/p/mtest-sf/wiki/%E4%B8%AD%E6%96%87%E5%B8%AE%E5%8A%A9/

  1. In mtest-sample-1.0.0-sources.jar, the sample code

    @Scenario(Priority = "P1", Author = "Miansheng", Param = "{'letter':['a', 'b', 'c'], 'number':['1', '2', '3'], 'other':['x', 'y']}", Combine = "letter,number,other", Strategy = "product", Condition = "limitParam")
    public void productTestCase(String letter, int number, String other) {

    Logger.info(this.param.toString());
    

    }

    @Test
    @TestParam(Param = "{'a':'b'}")
    @TestDesp(Author = "Miansheng", Priority = "P1", TestType = "TestDespAuto", Desp = "This is a junit test example")
    public void junitTestCase() {
    Logger.step("This is a step");
    Logger.input("This is a input");
    Logger.warn("This is a warn");
    Logger.info(this.param.toString());
    Logger.step("This is a step");
    Logger.error("This is an error");
    Logger.info(this.param.toString());
    }

  2. In the build directory, execute the command:
    java -jar mtest-driver-1.0.0.jar -t mtest-sample-1.0.0.jar -f "."
    The test result will be,
    …….
    Test Summary:


Passed Test Case(1):
org.mtest.sample.simplecase.UseTestLogSample
useStepInTestCase

Failed Test Case(2):
org.mtest.sample.simplecase.UseTestConfigSample
getTestConfigInTestCase
org.mtest.sample.simplecase.SimpleJunitTestCase
junitTestCase

Total Case(3):
Passed: 1 + Failed: 2 + NotRun: 0

Test Log File:
testreport.html