I think Scott and Glen are both pointing out that your method in your controller class that is not associated with a route ("filter") is not a method of your controller, but instead in the "model" portion of MVC. It might help you to move that code outside of the controller class, and then it'll make much more sense to test it normally with Test::More instead of Test::Mojo.
# lib/App/Controller/This.pm package App::Controller::This; use Mojo::Base 'Mojolicious::Controller'; sub list { my $self = shift; my $model = App::Model->new; my $value = $self->req->json('/value'); $self->render(json => {value => $model->filter(@$value)}); } # lib/App/Model.pm package App::Model; use Mojo::Base -base; sub filter { my $self = shift; my $final; /something/ and push @$final, $_ for @_; return $final; } And then you can test your filter method normally: # t/basic.t use Test::More; use Test::Mojo; # Test the controller / action and the use of any models my $t = Test::Mojo->new('App'); $t->get_ok('/list' => json => {value => ['abc', 'def something ghi', 'jkl', 'mno something pqr']}) ->status_is(200) ->json_is('/value', ['def something ghi', 'mno something pqr']); # Test just the model my $model = App::Model->new; isa_ok $model, 'App::Model'; is_deeply $model->filter('abc', 'def something ghi', 'jkl', 'mno something pqr'), ['def something ghi', 'mno something pqr']; On Mon, Apr 27, 2020 at 10:46 PM Glen <g...@empireenterprises.com> wrote: > He's implying that you wouldn't test this internal method with Test::Mojo; > Test::Mojo > is for testing endpoints. > > If you want to test a specific method that is not an endpoint, load the > module manually and test it with Test::More. > > On Apr 27, 2020, 11:32 PM -0400, Alberto Mijares <amijar...@gmail.com>, > wrote: > > > > On Mon, Apr 27, 2020, 7:09 PM Scott Wiersdorf <scott.wiersd...@gmail.com> > wrote: > >> Test::Mojo can help you test your views and controllers, as well as your >> internal helpers: >> >> >> https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Testing.pod#Testing-application-helpers >> > > Thank you Scott. > > I did read the documentation before writing this email and saw what you > are pointing out. The thing is: it's not clear enough for me. > > Given the example in my original post, could you give me a more detailed > explanation? I don't know how to trigger this specific method. > > Thanks in advance for your help. > > Alberto Mijares > > >> -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/mojolicious/CAGZBXN9VBvBFZdkmpaJOPHFJ5V5h98GdqmsqjH%2B7wN6bRNpAuQ%40mail.gmail.com > <https://groups.google.com/d/msgid/mojolicious/CAGZBXN9VBvBFZdkmpaJOPHFJ5V5h98GdqmsqjH%2B7wN6bRNpAuQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/mojolicious/985dbe91-4202-406e-9b28-dd44922933a7%40Spark > <https://groups.google.com/d/msgid/mojolicious/985dbe91-4202-406e-9b28-dd44922933a7%40Spark?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFSRKsEpxnRvmP1MJ9mHpQVZq9SqhUUiywOS3zuROj5nDQ%40mail.gmail.com.