Mock UObject in C++

Hi mates. So I have two classes placed in separated files:

UCLASS()
class UFirst : public UObject
{
    GENERATED_BODY()
public:
    UFUNCTION()
	virtual void function(const UObject* obj)
	PURE_VIRTUAL(UFirst::function);
}

UCLASS()
class UFirstMock : public UFirst
{
    GENERATED_BODY()
public:
    MOCK_METHOD(void, function, (const UObject*), (override));
}

but when I’m using UFirstMock in test file like this:

UFirstMock* fMock = NewObject<UFirstMock>();
EXPECT_CALL(*fMock , function(testing::_)).Times(1);

I got this error: “unknown file: error: SEH exception with code 0xc0000005 thrown in the test body.”

Could somebody tell me please what I do wrong to mock a UObject?

Think I found out the solution. In not test impl of UFirst I have a GetWorld()-> code. I added above UFirstMock* fMock = NewObject<UFirstMock>(); these lines:

UWorld* World = UWorld::CreateWorld(EWorldType::Game, false);
FWorldContext& WorldContext = GEngine->CreateNewWorldContext(EWorldType::Game);
WorldContext.SetCurrentWorld(World);

const FURL url;
World->InitializeActorsForPlay(url);
World->BeginPlay();

UFirstMock* fMock = NewObject<UFirstMock>(World);

Now it works