github.com/vmware/govmomi@v0.37.2/govc/test/README.md (about)

     1  # Functional Tests for govc
     2  
     3  The govc tests use [bats](https://github.com/sstephenson/bats/), a framework that provides a simple way to verify *NIX programs behave as expected.
     4  
     5  ## Enabling ESX Tests
     6  
     7  Some of the govc tests require an ESX instance. These tests may be enabled with any ESX host with the following environment variable:
     8  
     9  ```
    10  GOVC_TEST_URL=user:pass@<ESX_HOST>
    11  ```
    12  
    13  ## Running Tests
    14  
    15  There are two ways to run the tests locally:
    16  
    17  1. [_Via GitHub Actions in Docker_](#run-tests-via-github-actions-in-docker) - mimics how GitHub actions will execute the tests
    18  2. [_Natively on Linux and macOS_](#run-tests-natively-on-linux-and-macos) - the fastest way to run the tests
    19  
    20  ### Run Tests via GitHub Actions in Docker
    21  
    22  This method of running the govc functional tests mimics how the project's associated GitHub actions will execute the tests when new pull requests are opened:
    23  
    24  1. Install [`act`](https://github.com/nektos/act):
    25  
    26      * Linux (curl bash)
    27  
    28          ```shell
    29          curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
    30          ```
    31  
    32      * macOS
    33  
    34          ```shell
    35          brew install act
    36          ```
    37  
    38      * [_Documentation for other installation methods_](https://github.com/nektos/act#installation)
    39  
    40  2. Run the `govc-tests` action:
    41  
    42      ```shell
    43      act --env USER=user -j govc-tests
    44      ```
    45  
    46      ---
    47  
    48      **Note**: To run the ESX tests with `act`, execute the following command:
    49  
    50      ```shell
    51      act --env USER=user --env GOVC_TEST_URL="user:pass@<ESX_HOST>" -j govc-tests
    52      ```
    53  
    54      ---
    55  
    56  ### Run Tests Natively on Linux and macOS
    57  
    58  The fastest way to run the tests is to do so natively on Linux or macOS:
    59  
    60  1. Install [bats](https://github.com/sstephenson/bats/):
    61  
    62      * Debian / Ubuntu Linux
    63  
    64          ```shell
    65          apt-get install bats
    66          ```
    67  
    68      * macOS
    69  
    70          ```shell
    71          brew install bats
    72          ```
    73  
    74      * [_Installing bats from source_](https://github.com/sstephenson/bats#installing-bats-from-source)
    75  
    76  
    77  2. Some tests depend on the `ttylinux` images, and they can be downloaded with the following command:
    78  
    79      ```shell
    80      ./govc/test/images/update.sh
    81      ```
    82  
    83      The images are uploaded to the `$GOVC_TEST_URL` as needed by tests and can be removed with the following command:
    84  
    85      ```shell
    86      ./govc/test/images/clean.sh
    87      ```
    88  
    89  ---
    90  
    91  **Note**: Users of macOS will want to install `gxargs`, `greadlink`, and `gmktemp` with the following command:
    92  
    93  ```shell
    94  brew install coreutils findutils
    95  ```
    96  
    97  ---
    98  
    99  3. The easiest way to run the tests is with the top-level Makefile:
   100  
   101      ```shell
   102      make govc-test
   103      ```
   104  
   105      The tests can also be run directly with the `bats` command:
   106  
   107      ```shell
   108      bats -t ./govc/test/
   109      ```
   110  
   111      Finally, it's also possible to run the tests individually with:
   112  
   113      ```shell
   114      ./govc/test/cli.bats
   115      ```