Java – Python unit tests almost never check types
•
Java
I'm using JUnit to do some tests written in Java, but I can't notice the focus of checking object "types" This is something I've never seen in the python test suite
Java is statically typed while Python is dynamically typed. Shouldn't it be the opposite?
Solution
In dynamically typed languages, developers often follow the duck typing principle - "if it looks like a duck and walks like a duck, it's a duck." As long as the object completes all the operations required for testing, does it really matter what type of object it is? The duck typed and said no
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码