How to unit test a MonoBehaviour which has RequireComponent attribute ?

using UnityEngine;

[RequireComponent(typeof(Rigidbody), typeof(Collider))]
public class ClassToTest : MonoBehaviour {
    public bool TestFunction() { return false; }
}

using NUnit.Framework;
using UnityEngine;

namespace Tests.Editor
{
	public class ClassTesterEditMode
	{
		private ClassToTest _classToTest;

		public ClassTesterEditMode()
		{
			GameObject gameObject = new GameObject();
			_classToTest = gameObject.AddComponent<ClassToTest>();
		}


		[Test]
		public void TestOne()
		{
			Assert.False(_classToTest.TestFunction());
		}
    }
}

When I remove the RequireComponent attribute, I won’t get System.NullReferenceException : Object reference not set to an instance

How can I keep the RequireComponent attribute and bypass the nullreference error?

(by the way, I know I haven’t used good names, since I wanted to keep it simple and get the message across)

I really appreciate any help you can provide.

How can I keep the RequireComponent attribute and bypass the nullreference error?

Simply add the required components in the constructor of your ClassTesterEditMode the same way you add ClassToTest