Ben Chuanlong Du's Blog

It is never too late to learn.

Kotlin Unit Testing

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Use Java reflection to help test private methods.

https://phauer.com/2018/best-practices-unit-testing-kotlin/

https://medium.com/mindorks/how-to-unit-test-private-methods-in-java-and-kotlin-d3cae49dccd

Java Unit Testing

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

import static org.junit.Assert.*;

assertEquals

assertArrayEquals

Use reflection to test private methods.

References

https://javarevisited.blogspot.com/2018/09/junit-testing-tips-constructor-is-called-before-test-methods.html

https://medium.com/mindorks/how-to-unit-test-private-methods-in-java-and-kotlin-d3cae49dccd

Hands on the urllib Module in Python

Comments

  1. It is suggested that you use the requests module instead of urllib unless you want to have minimal 3rd-party dependencies.

  2. You have to explicit import urllib.request in order to use it in Python 3. Please refer to https://bugs.python.org/issue36701 for more discussions. This is how Python 3 intends to work generally speaking. Of course, there are a few exceptions such as os.path