1

I have a list of functions I'm trying to test with dapptools, but I only want to test one. How do I accomplish this?

// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "../DappLottery.sol";
import "ds-test/test.sol";

contract DappLotteryTest is DSTest {
    DappLottery public dappLottery;

    function setUp() public {
        dappLottery = new DappLottery();
    }

    function test_consumer_can_start_lottery() public {
        bool response = dappLottery.startLottery();
        assertTrue(response);
    }

    function test_consumer_can_end_lottery() public {
        bool response = dappLottery.end();
        assertTrue(response);
    }
}
Patrick Collins
  • 5,621
  • 3
  • 26
  • 64

1 Answers1

1

You can use the -m "match" flag to search for a regex string that matches the test name you want.

For example:

dapp test -m test_consumer_can_end_lottery

Or

dapp test -m test_consumer_can_start_lottery
Patrick Collins
  • 5,621
  • 3
  • 26
  • 64
  • 1
    Yep. Here are all the options: [dapp doc #test](https://github.com/dapphub/dapptools/blob/master/src/dapp/README.md#dapp-test) – Caio Mar Jan 14 '22 at 02:26