Shellscript automated testing framework-shUnit2

Source: Internet
Author: User

Shellscript automated testing framework-shUnit2

Development background of shUnit2

ShUnit2 is developed based on the log4sh SHELL automated testing. It is used in a similar way as JUnit.

Preparation

1. Download shUnit2

Wget-P ~ /Download http://shunit2.googlecode.com/files/shunit2-2.1.6.tgz

2.Extract

tar -xzvf ~/download/shunit2-2.1.6.tgz

3. Execute Test Cases

~/download/shunit2-2.1.6/examples/equality_test.sh
Internal processing of test execution

The internal processing process of shUnit2 is as follows.

When shunit2 is executed, the oneTimeSetUp function, which starts with "test", is defined, the test functions listed in this function are executed as follows: if the setUp function is defined and the execution test function tearDown function is defined, the system executes the function when the oneTimeTearDown function is defined.
. "$SHUNIT2_HOME"/src/shell/shunit2
Generate Test code

Example:

#! /Bin/sh # file: test/my_function_test.sh # Read the test object... /src/my_function.shoneTimeSetUp () {:} oneTimeTearDown () {:} setUp () {:} tearDown () {:}# test case testMyFunction () {assertTrue "['myfunction 2'-eq 4]"}. "$ SHUNIT2_HOME"/src/shunit2
#!/bin/sh# file: src/my_function.shmyFunction() {  echo `expr $1 \* $1`}

Reference: http://d.hatena.ne.jp/oknknic/20110823/1314113501

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.