Skip to content

Instantly share code, notes, and snippets.

View vadymhimself's full-sized avatar

Vadym O. vadymhimself

  • Bali, Indonesia
View GitHub Profile
@vadymhimself
vadymhimself / unit-tests.md
Last active July 20, 2018 23:14
Writing Great Unit Tests: Best and Worst Practices

This blog post is aimed at developers with at least a small amount of unit testing experience. If you've never written a unit test, please read an introduction and have a go at it first.

What's the difference between a good unit test and a bad one? How do you learn how to write good unit tests? It's far from obvious. Even if you're a brilliant coder with decades of experience, your existing knowledge and habits won't automatically lead you to write good unit tests, because it's a different kind of coding and most people start with unhelpful false assumptions about what unit tests are supposed to achieve.

Most of the unit tests I see are pretty unhelpful. I'm not blaming the developer: Usually, he or she just got told to start unit testing, so they installed NUnit

package com.clockwidget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import java.util.Calendar;
@vadymhimself
vadymhimself / Rate.java
Created November 12, 2015 13:19
Yahoo Rates JAXB
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "rate")
public class Rate {
@XmlElement(name = "Name")
String name;
@XmlElement(name = "Rate")
String rate;
import com.sun.istack.internal.Nullable;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
/**
* serializes only fields marked with @Save annotation