github.com/kchristidis/fabric@v1.0.4-0.20171028114726-837acd08cde1/test/regression/daily/chaincodeTests/README.rst (about) 1 Chaincode Test Framework 2 ========================================================================== 3 4 Framework Capabilities 5 ------------------------------------------------------------------------ 6 7 * Verifies Hyperledger-Fabric features by executing your chaincode 8 * Supports any chaincodes written in **GO** 9 * Spins up a docker network and runs CLI test scripts 10 * Tests all contributed chaincodes as part of our daily Continuous Integration (CI) test suite, and displays XML Reports for each chaincodee 11 12 13 How to Plug In *YourChaincode* 14 --------------------------------------------------------------------------- 15 16 * Using **GO** language, write *YourChaincode* and place it at *fabric/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/go/<YourChaincodeDir>/<YourChaincode.go>* 17 * Write a CLI bash script such as *e2e_test_<YourChaincode>.sh* to execute invokes and queries using your chaincode API, and place it under *fabric/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/* 18 19 * Simply model it after others, such as *e2e_test_example02.sh* 20 * During the install step, give the path to chaincode as *github.com/hyperledger/fabric/test/regression/daily/chaincodeTests/fabricFeatureChaincodes/go/<YourChaincodeDir>* 21 * Note: **test_AFAB3843_Create_Join_Channel** must be run as first test step 22 23 * Add a few lines to define your new test inside *test/regression/daily/chaincodeTests/envsetup/testYourChaincode.py* 24 25 * Copy the few lines from another example such as 'def test_example02', and simply change the name and path 26 27 =========================================================================== 28 29 30 How to Run the Chaincode Tests 31 ------------------------------------------------------------------------ 32 33 ``$ cd fabric/test/regression/daily/chaincodeTests`` 34 ``$ ./runChaincodes.sh`` 35 36 *runChaincodes.sh* calls *testYourChaincode.py* 37 38 ``py.test -v --junitxml YourChaincodeResults.xml testYourChaincode.py`` 39 40 The output should look like the following: 41 42 :: 43 44 ========================= 45 test session starts 46 ========================= 47 platform linux2 -- Python 2.7.12, pytest-2.8.7, py-1.4.31, pluggy-0.3.1 -- /usr/bin/python 48 cachedir: .cache 49 rootdir: /opt/gopath/src/github.com/hyperledger/fabric/test/regression/daily/chaincodeTests/envsetup, inifile: 50 collected 3 items 51 testYourChaincode.py::ChaincodeAPI::test_AFAB3843_Create_Join_Channel PASSED 52 testYourChaincode.py::ChaincodeAPI::test_FAB3791_example03 PASSED 53 testYourChaincode.py::ChaincodeAPI::test_FAB3792_marbles02 PASSED 54 55 56 Logs 57 ------------------------------------------------------------------------------- 58 Logs from each test script are redirected and stored at envsetup/scripts/output.log 59 60 61 Deactivate Network 62 ------------------------------------------------------------------------------- 63 The network is automatically deactivated as part of the teardown step after running all tests. 64 In case of trouble, here is how to deactivate docker network manually: 65 66 ``cd /path/to/fabric/test/regression/daily/chaincodeTests/envsetup`` 67 ``./network_setup.sh down`` 68 69 .. Licensed under Creative Commons Attribution 4.0 International License 70 https://creativecommons.org/licenses/by/4.0/