-
Notifications
You must be signed in to change notification settings - Fork 0
robinjha/dynamic_testing_python
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Files:
palindrome.py - code
palindrometest.py - unit test
cases.txt - CSV test file
Assumptions/specifications:
1. Implementation is case sensitive.
2. Implementation does not account for white spaces and punctuation.
3. Empty string returns true
Solution:
In my current implementation you don\'92t need to write the test cases for each scenario.
You can just add the input and the expected value along with the function name in a csv file
and pass it as a command line argument. The function will then create individual test cases.
Run:
python palindrometest.py cases.txt
Output:
you can pass the name of the file which has the test cases as an argument
In setUp()
\{'3_neg': ['volumes', 'False\\n'], '4_pos': ['v', 'True\\n'], '5_pos': ['', 'True'], '2_pos': ['radar', 'True\\n'], '1_pos': ['abba', 'True\\n']\}\
Setup complete\
('volumes', 'False\\n')\
('v', 'True\\n')\
('', 'True')\
('radar', 'True\\n')\
('abba', 'True\\n')\
('volumes', 'False\\n')\
('v', 'True\\n')\
('', 'True')\
('radar', 'True\\n')\
('abba', 'True\\n')\
..........\
----------------------------------------------------------------------\
Ran 10 tests in 0.001s\
\
OK\
\
Option 2:\
test_gen_1_pos (__main__.is_palindrome_Test_1_pos) ... ok\
test_gen_2_pos (__main__.is_palindrome_Test_2_pos) ... ok\
test_gen_3_neg (__main__.is_palindrome_Test_3_neg) ... ok\
test_gen_4_pos (__main__.is_palindrome_Test_4_pos) ... ok\
test_gen_5_pos (__main__.is_palindrome_Test_5_pos) ... ok\
test_gen_1_pos (__main__.is_palindrome_rec_Test_1_pos) ... ok\
test_gen_2_pos (__main__.is_palindrome_rec_Test_2_pos) ... ok\
test_gen_3_neg (__main__.is_palindrome_rec_Test_3_neg) ... ok\
test_gen_4_pos (__main__.is_palindrome_rec_Test_4_pos) ... ok\
test_gen_5_pos (__main__.is_palindrome_rec_Test_5_pos) ... ok\
\
----------------------------------------------------------------------\
Ran 10 tests in 0.001s\
\
OK\
}
About
Dynamic generation of tests in Python unittest framework
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published