Unit testing


I’ve looked through numerous posts but never found any satisfying answer. I have developed some streamlit apps that grew relatively complex over time.

I was wondering if anyone had managed to design a good testing framework. In the past I have tested some light apps by using mock objects to simulate the behavior of widgets but that gets heavy very quickly, the tests take forever to write and they are not even easy to read (which defies the purpose of testing in my opinion).

Has anyone thought about this problem? Would it make sense to have some sort of framework where you can easily simulate a user input (maybe by leveraging the widget key and automatically replace it by test values)?

I’d love to hear ideas on this topic.


Hi @fdubinski -

Testing Streamlit apps is a popular topic lately :slight_smile: I’m in the middle of writing a blog post to show how you can use SeleniumBase with Streamlit, but I only focused on the visual aspects of an app. You can take a look at how to set this up in my streamlit-folium repo:

Selenium in general is for browser automation, so I have no doubt that you could figure out how to use it to submit inputs, then test the result.