If you want to test whether the exit status of your command indicates success or failure, leave off the brackets entirely; using the test command in that use case is wrong, full-stop.
In this case,
if foo "$param1" "$param2"; then ...; fi
is the only correct syntax that isn't needlessly inefficient.
It's certainly possible to emit $? inside your subprocess, and check the output of that using test, like so:
if [ "$(foo "$param1" "$param2" >&2; echo "$?")" -eq 2 ]; then ...; fi
...but see again re: "needlessly inefficient"; this would be better written as:
foo "$param1" "$param2"; retval=$?
if [ $retval -eq 2 ]; then ...; fi
...avoiding all the overhead of an unnecessary subshell.
If you want to test whether the output of your command is non-empty (typically an undesirable / unnecessary operation, as most standard UNIX commands can indicate whether they operated correctly, whether they found what they were searching for, etc. via exit status):
if [ -n "$(foo "$param1" "$param2")" ]; then ...; fi
is correct.
One important thing to keep in mind -- any use of $() moves your function from running inside of the parent shell (and thus able to update or modify that shell's state) into a subshell. So -- if your function is supposed to change variables or state inside the shell, using $() will modify its behavior.
testcommand.test? Are you trying to test whether it emits output, rather than its exit status?testworks.