Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Databricks unit testing with Nutter

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

like image 846
Enrique Benito Casado Avatar asked Aug 22 '26 15:08

Enrique Benito Casado


1 Answers

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())
like image 160
dangob Avatar answered Aug 25 '26 05:08

dangob