Over a million developers have joined DZone.

Developing (a.k.a. Testing) in Python - Part 1: Python and Java

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.

Before coming to Fiesta I had worked with Java almost exclusive for the past six years. The codebase at my previous company was about 2,000 files and 300,000 LOC. I’m fairly fluent in Java, but I’ve also been a longtime Python advocate; I was excited to jump into a larger, more collaborative Python project than what I’ve put together over the years.

I’d like to take some time to talk about how the experience has gone so far. In this post, I’ll share my thoughts on testing in Python:

Running test cases is Python’s version of compile-time checking.

Running our collection of tests (using nose) on a bunch of symbol changes (e.g. changing variable names or method signatures) often leads to a bunch of errors and failures. At the same time, refactoring some code in a large Java project could easily produce hundreds of compile errors. Comparing the time spent getting tests to pass versus getting Java code to compile, it feels like a push. However, when comparing my confidence that things are working, Python comes out ahead.

This confidence through testing is only possible because of Fiesta’s extensive set of test cases; there are more LOC in the test files than in the application itself. Our testing goal isn’t to test every method, but rather to cover all of the actions a user can take. In that vein, almost all tests are end to end.

I find it more natural to write tests in Python than in Java. With Java and other compiled languages, I typically feel that once I get something to compile, it will work. That’s rarely the case, but that feeling subtly influences me to not write testing code alongside the logic code. When writing for Python, I’m often using the interpreter and generally find myself wanting to save my progress. It just makes sense to piece things together in a test function and place asserts when I want to pin logic into place.

Given my experiences so far, I’m not sure if developing in Python is any faster or slower than doing so in Java, but the time is definitely spent on different things. I’d like to do some more posts on this topic in the future, so let me know your thoughts/questions in the comments.

Party On.

Dan

 

source: http://blog.fiesta.cc/post/11060794329/developing-a-k-a-testing-in-python

From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}