C# NullReferenceException with GetComponent issue

I’m having another problem when it comes to GetComponent, as it says it’s coming up as a null reference.

I’ve attempted making the code many different ways but this always pops up.The current test code that I’m applying is:

public class anotherTest : MonoBehaviour 
{
	public GameObject Miles;
	// Use this for initialization
	void Start () 
	{
		Miles.GetComponent<test>().Health = 400;
		Debug.Log (Miles.GetComponent<test>().Health);
		
		
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (Input.GetKeyDown(KeyCode.B))
		{
			Miles.GetComponent<test>().Health = Miles.GetComponent<test>().Health + 400;
			Debug.Log (Miles.GetComponent<test>().Health);
			
		}
	
	}
}

After fighting with GetComponent for awhile, I’ve turned to this as being one of the only ways I’ve found that compiles without fail.

The base class that the code is coming from is literally a monobehavior class with just a public int “Health.”

The only thing I’m trying to accomplish with this is to see the values every time I hit B to make sure it works. Every time I hit B, though, I get hit with the error. (and also at initialization)

I’m probably missing at least 1 line of code, so could anyone try to point me in the right direction?

Thanks in advanced for helping sort out this issue!

Well, if this compiles ok, the problem probably is the script test.cs not being attached to the object referenced by Miles, or Miles was not assigned in the Inspector.