squaretest

Open full view…

Google Truth

andyjohn
Fri, 06 Sep 2019 00:48:03 GMT

Has anyone created a version of the template to use Google's Truth library: com.google.common.truth.Truth.assertThat ... assertThat(n).isEqualTo(42); Also, is it possible to add a new slot to the template menu in the config? Thanks, Andy

andyjohn
Fri, 06 Sep 2019 00:58:52 GMT

(Nevermind that last part, read about the Save Template As button)

andyjohn
Fri, 06 Sep 2019 05:25:14 GMT

Well, this hack seems to work: import static com.google.common.truth.Truth.assertThat; ..... #macro(assertEqualsCall $expected, $actual, $type) #if($type.array) assertThat($actual).isEqualTo($expected) #break ## break is needed to avoid adding a newline. #elseif($StringUtils.equalsAny($type.canonicalName, 'double', 'java.lang.Double')) assertThat($actual).isWithin(0.0001).of($expected) #break #elseif($StringUtils.equalsAny($type.canonicalName, 'float', 'java.lang.Float')) assertThat($actual).isWithin(0.0001).of($expected) #break #elseif($StringUtils.equalsAny($type.canonicalName, 'boolean', 'java.lang.Boolean')) assertThat($actual).isTrue() #break #else assertThat($actual).isEqualTo($expected) #end #end