Calling function from an onlyOwner smart contract

I have two separate contract files. One is the source contract to test and the other is a foundry test contract.

Source Contract

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

contract Helloworld is
  uint256 public idCounter;
  function setCounter(uint256 counter_) public onlyOwner {
        require(counter_ != 0, "Counter cannot be 0");
        counter = counter_;
   function counterCheck() external payable {
        require(msg.value == counter, "Invalid counter");

        unchecked {

        _safeMint(msg.sender, idCounter, "");


I also have the below foundry test case in the below test contract when I am receiving [FAIL. Reason: revert: Ownable: caller is not the owner] error.

I tried inheriting the source contract as in the below code.

Requirement: Become the contract owner or run the test without the owner error.

NB: The overflow issue in the code is known. The foundry test case is planned to address it.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "./sourcecontract.sol";
import "forge-std/Test.sol";

contract chilcontract is Helloworld{
  Helloworld public hw;

contract countertest is Test{
  childcontract childInstance;
  function setUp() public{
    childInstance = new childcontract();

  function testcounter() public{

    //set counter
    uint256 counter = 1 ether;// counter set to 1 ether
    console.log("Counter set");

I came to know that the constructor cannot be used since I am using the OwnableUpgradeable library.

I added function initialize() public initializer { __Ownable_init(); } above the setup function, however while running the forge test, produced the same error. I couldn't find a foundry test case based on this logic

You can try Foundry's prank cheatcodes. See this example.