The owner of `contract DormantAsset` is `dormant_asset_factory` and you are trying to execute `setHeir()` function from `accounts[0]`. Function `setHeir()` has modifier `onlyOwner` and we already know that the owner is factory contract. You should implement function `callSetHeir()` in your **factory** contract and then call it from your test. Hope it helps. ---------- ***Bonus:** more readable way to write function with returned value* function newDormantAsset() public returns(address c) { DormantAsset c = new DormantAsset(_heartbeatTimeout); dormantAssets.push(c); }