javafitnessefitnesse-slim

How do I load a customcomparator in a fitnesse test


I created a custom comparator for Fitnesse, and attempted to load it, but I can't get it to work. It's just completely ignored in my script table, and it does a direct string equality comparison.

Comparator:

package com.company;
import fitnesse.testsystems.slim.CustomComparator;

public class ContainsComparator implements CustomComparator{

    @Override
    public boolean matches(String actual, String expected) {
        if(actual != null && actual.contains(expected)){
            return true;
        }
        else{
            return false;   
        }
    }
}

Test Page contents:

!define TEST_SYSTEM {slim}
!path C:\Path\To\My\Comparator.jar

!|Import|
|fitnesse.fixtures|

!| SetUp | CustomComparators=contains:com.company.ContainsComparator |

!|Script|com.company.SomeFixture|
|check| response|contains:something|

Only the last check fails, returning: [Something there] expected [contains:Something]. There's no other exceptions or failures (Setup doesn't throw an error, for example)

I followed examples from http://fitnesse.org/FitNesse.SuiteAcceptanceTests.SuiteSlimTests.TestCustomComparators and http://www.fitnesse.org/FitNesse.UserGuide.AdministeringFitNesse.ConfigurationFile to get this far, but I can't find any further documentation on this.


Solution

  • Try registering the custom comparator via the plugins.properties file.