Unit testing

Hi,

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.

Thanks
Fred

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.

2 Likes

Hey @randyzwitch, regarding that blog post, is it posted somewhere or is it still WIP? Thnx!

Welcome to the Streamlit community @iavorbotev!

I’m sad to say I’m still working on it, but it’s supposed to be published tomorrow. :grimacing:

Thanks! Awesome, looking forward to it!

Here it is!

3 Likes

That’s really cool, thanks, I will check it out!

1 Like