How do I define the default cache and cache settings programmically in a Kernel test?
Take a look the Memcache module.
The module has tests, and seems you need write

  protected function setUp() {
    $this-&gt;config = [
      'memcache' =&gt; [
        'servers' =&gt; ['127.0.0.2:12345' =&gt; 'default'],
        'bin' =&gt; ['default' =&gt; 'default'],
      ],
      'hash_salt' =&gt; $this-&gt;randomMachineName(),
    ];
    $settings = new Settings($this-&gt;config);
    $this-&gt;settings = new MemcacheSettings($settings);
  }