Hi Monks ! I appeal to your legendary wisdom. I have this following issue. I created a timer to get time elapsed between beginning of my tests and the end of them. But depending where i put my "end time" line, i have a different output in my Shell. I did this code :
use Modern::Perl; use strict; use warnings; package MyTestingSuite; use parent 'Test::Class'; use Test::Selenium::Remote::Driver; use Test::More; use POSIX qw(strftime); my $start = time(); cprint "Started at ", (strftime '%A %d %B %Y %H:%M:%S',localtime($star +t)), "\n"; sub startup : Test( startup => no_plan ) { my $self = shift; $self->{browsers} = [('firefox', 'internet explorer', 'chrome', 'pha +ntomjs')]; } # WHEN I PUT MY END TIME HERE: my $end = time(); cprint "Ended at ", (strftime '%A %d %B %Y %H:%M:%S', localtime($end +)),"\n"; cprintf "Total run time:", $end-$start, " seconds\n"; printf ("%02d:%02d:%02d\n",(gmtime($end-$start))[2,1,0]); I HAVE THIS OUTPUT IN MY SHELL: Started at 2016-05-17-16-55-00 1..0 Ended at 2016-05-17-16-57-04 Total run time:0 seconds .....ALL MY TESTS ..... sub Login_test : Tests { $driver->quit(); } } sub Logout_test : Tests { $driver->quit(); } } sub Navigation_test : Tests { $driver->quit(); } # WHEN I PUT MY END TIME HERE: my $end = time(); cprint "Ended at ", (strftime '%A %d %B %Y %H:%M:%S', localtime($end +)),"\n"; cprintf "Total run time:", $end-$start, " seconds\n"; printf ("%02d:%02d:%02d\n",(gmtime($end-$start))[2,1,0]); I HAVE THIS OUTPUT IN MY SHELL: Started at 2016-05-17-16-57-04 1..0 ....ALL MY TESTS ..... Ended at 2016-05-17-17-03-04 Total run time:360 seconds }

So in second position, inside Sub, it works fine , because i have all my tests inside my timer and so i can have elapsed time. But problem is that i can have random sub in my test . Also even if i place my end timer in the last Sub it can cut my timer inside my tests and not at the end of end.

I think about a conditionnal loop to get all my sub when they finish all to call my end time but i don't know how .

How can i do?

Many Thanks !


In reply to Time elapsed with Selenium Test by Chaoui05

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.