Same issue. Not sure what I'm doing wrong.
So I've taken to including a main() in each test file and adding each test function there:
file: test_stuff.mojo
def test_A():
print("test_A: ", end="")
# do stuff
print("PASS")
def test_B():
print("test_B: ", end="")
# do stuff
print("PASS")
def main():
print("##### test_stuff.mojo, start")
test_A()
test_B()
print("all tests passed")
Then, I can do a shell command to run them all:
find ./ -type f -name "test_*.mojo" -execdir mojo "{}" \;
Output:
##### test_stuff.mojo, start
test_A: PASS
test_B: PASS
all tests passed
##### test_some_other_file_that_is_not_shown_above.mojo, start
test_ok: PASS
test_some_failure: AssertionError: `left == right` comparison failed:
left: 1
right: 2
mojo: error: execution exited with a non-zero result: 1
Not pretty, but is a workaround until I figure out what I'm doing wrong that prevents mojo test from picking up my test files & functions. 😊
oh wow. I was just goofing around a bit and removed the init.mojo file; now mojo test works. Although I need to rework my test code, as removing the init file messed with my imports. Hmmm....