Created
March 5, 2011 13:17
-
-
Save KengoTODA/856348 to your computer and use it in GitHub Desktop.
test case generator for partake.in (trial)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # test case generator for partake.in | |
| create_testcase_filename() { | |
| _wordcount=`echo $2 | wc -c` | |
| _wordcount=`expr $_wordcount - 2` | |
| _target=`echo $2 | cut -c 1 | tr '[a-z]' '[A-Z]'` | |
| _target=$_target`echo $2 | cut -c 2-$_wordcount` | |
| echo ${_target}`echo $3 | sed -e s/TestCaseBase/Test/` | |
| } | |
| create_testcase() { | |
| _basefilename=$1 | |
| _tmp=${_basefilename##*/} | |
| _basefilename=${_tmp%.*} # remove extension | |
| _testcasename=`create_testcase_filename $1 $2 $_basefilename` | |
| _target=`echo $2 | tr -d '/'` | |
| cat << _EOT_ > $2/$_testcasename.java | |
| // common test cases are written in the super class. | |
| package in.partake.service.${_target}; | |
| import org.junit.AfterClass; | |
| import org.junit.BeforeClass; | |
| import in.partake.resource.PartakeProperties; | |
| import in.partake.service.${_basefilename}; | |
| public class $_testcasename extends $_basefilename { | |
| @BeforeClass | |
| public static void setUpOnce() { | |
| PartakeProperties.get().reset("${_target}"); | |
| reset(); | |
| } | |
| @AfterClass | |
| public static void tearDownOnce() { | |
| PartakeProperties.get().reset(); | |
| reset(); | |
| } | |
| } | |
| _EOT_ | |
| } | |
| for _dir in `ls -p1 | grep '/$'` | |
| do | |
| if [ _$_dir = _"mock/" ]; then | |
| # skip this folder because its test cases should be written by hand. | |
| continue | |
| fi | |
| for _testcase in `ls -p1 *.java | grep -v '^Abstract'` | |
| do | |
| create_testcase $_testcase $_dir | |
| done | |
| done | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment