schmidmt / shunit2

Automatically exported from code.google.com/p/shunit2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shUnit2 can't find sourced tests?

GoogleCodeExporter opened this issue · comments

What steps will reproduce the problem?
1. Set up a script which is meant to bring in all tests:
----- script -----
#!/bin/bash

# contains a test function, named correctly, simple assertEquals 1 1 statements 
within
source path/to/testMyFunc.sh

# this DOES recognize the test function
# type testMyFunc

# now try to bring in shunit2
source path/to/src/shunit2
----- /script -----

What is the expected output? What do you see instead?
EXPECTED:
testMyFunc

Ran 1 tests.

OK


ACTUAL:

Ran 0 tests.

OK


What version of the product are you using? Can you provide the output from
the lib/versions script included with the source?

$ shunit2-2.1.6/lib/versions
os: Mac OS X version: 10.X.X
shell: /bin/bash version: 3.2.48(1)-release
shell: /bin/dash version: not installed
shell: /bin/ksh version: 2011-02-08
shell: /bin/pdksh version: not installed
shell: /bin/sh version: unknown
shell: /bin/zsh version: 4.3.11


Please provide any additional information below.
I verified that the test function made it into the current scope of the script 
before shunit2 was sourced. I have no idea why this wouldn't function properly. 
Without the ability to source a handful of test functions before sourcing 
shunit2, the oneTimeSetUp, etc. functions are utterly useless. If I am 
restricted to setting tests up within the same file in which they are defined, 
those setups could just be put within the test function itself.  

Original issue reported on code.google.com by callmeSm...@gmail.com on 19 Nov 2013 at 9:39