Reputation: 2080
I m trying to run unit test inside Databricks with Nutter but return always None
notebook1
def add_nums(a, b):
return a + b
notebook2 (Where I want to make the unit test)
%pip install nutter
from runtime.nutterfixture import NutterFixture, tag
import the notebook1 in notebook 2
%run /notebook1/
I just make a tes to verify function in notebook1 is correctly added.
print(add_nums(1, 3)) # return 4 so everything fine.
class gcTestClass(NutterFixture):
def test_add(self):
assert (add_nums(1, 3) == 4)
result = gcTestClass().execute_tests()
print(result.to_string())
I get that output
Notebook: N/A - Lifecycle State: N/A, Result: N/A
Run Page URL: N/A
==================================================
No test cases were returned. Notebook output: None
could somebody help me to figure out what I m doig wrong ?
Thanks
Upvotes: 3
Views: 2256
Reputation: 56
You need to include "asssertion_" at the beginning of the assertion test function:
class gcTestClass(NutterFixture):
def assertion_test_add(self):
assert (add_nums(1, 3) == 4)
# COMMAND ----------
result = gcTestClass().execute_tests()
print(result.to_string())
Upvotes: 3