utPLSQL / utPLSQL-cli

Command line client for invoking utPLSQL
Apache License 2.0
40 stars 15 forks source link

Show current progress of tests run #117

Open pesse opened 5 years ago

pesse commented 5 years ago

If you run a larger set of tests it might be useful to indicate the current progress (n of m tests run) in the active console line (if Output is System.out),

This should not have any effect on the printed lines, though.

jgebal commented 5 years ago

This can be done within reporter. Reporter gets whole suite before run starts. The big quiestion is, should it be part of reporter ir part of API.

Should it be always enabled or optional? If we want it always enabled, we can add it into documentation reporter.

pesse commented 5 years ago

Does Reporter know when a test is finished? Does it even know which test is currently running?

I could imagine to add some new function to reporter API:

Would give a great way to increase user-feedback

jgebal commented 5 years ago

Reporters don't provide any get_ functionality. They are data-agnostic. They only provide stream of output text/data in specified format. Reporters are not interactive in that sence.

pesse commented 5 years ago

https://github.com/utPLSQL/utPLSQL/issues/795 might be sufficient as input to consume

PhilippSalvisberg commented 5 years ago

@pesse: you may initialize the new ut_realtime_reporter in the producer thread (as you do it already for other reporters) and consume the events you are interested in an additional thread for example this way:

select x.test_number, x.total_number_of_tests, x.utplsql_path
  from table(ut_output_table_buffer('7E45E66B02651B74E053020011AC0687').get_lines()) t,
       xmltable(
         '/event/test'
         passing xmltype(t.text)
         columns test_number           integer        path 'testNumber',
                 total_number_of_tests integer        path 'totalNumberOfTests',
                 utplsql_path          varchar2(1000) path '@id'
       ) x
 where t.item_type = 'pre-test';

In SQL*Plus I get a result like this:

TEST_NUMBER TOTAL_NUMBER_OF_TESTS UTPLSQL_PATH                                                                                                  
----------- --------------------- --------------------------------------------------------------------------------------
          1                   731 utplsql.core.test_ut_utils.trim_list_elements.test_trim_list_elements                                         
          2                   731 utplsql.core.test_ut_utils.trim_list_elements.trim_list_elemts_null_collect                                   
          3                   731 utplsql.core.test_ut_utils.trim_list_elements.trim_list_elemts_empty_collect                                  
          4                   731 utplsql.core.test_ut_utils.to_string.to_string_emptyblob                                                      
...
        728                   731 utplsql.api.test_ut_run.run_proc_transaction_control.run_proc_keep_test_data_raise                            
        729                   731 utplsql.api.test_ut_run.run_proc_transaction_control.run_proc_discard_test_data                               
        730                   731 utplsql.api.test_ut_run.ut_version                                                                            
        731                   731 utplsql.api.test_ut_run.ut_fail                                                                               

731 rows selected. 

You get an event (output row) exactly before a new test is executed. Based on that, showing progressing information should be simple.

See PR #809 for more information.