Testing using JUnit failed of a class
I have this class:

 

    public Statistics(long start_time,
                          long total_hit_count,
                          long emitted_bytes,
                          long idle_threads,
                          long total_threads) 
        {
            this.start_time = start_time;
            
            this.up_time = (System.currentTimeMillis() - start_time) / 1000;
            
            this.total_hit_count = total_hit_count;
            
            this.emitted_bytes = emitted_bytes;
            
            if(this.up_time > 0)
            {
                this.avghit_sec = ((float) this.total_hit_count) / ((float) this.up_time);
            }
            
            if(this.total_hit_count > 0)
            {
                this.avgbytes_hit = this.emitted_bytes / this.total_hit_count;
            }
            
            if(this.up_time > 0)
            {
                this.avgbps = this.emitted_bytes / this.up_time;
            }
            
            this.idle_threads = idle_threads;
            
            this.total_threads = total_threads;
        }

here it is my test class created with Junit.
my purpouse is to test that getavgbpg doesn't return 0 value but I get ArithmeticException even if I have if clause.

    public void testgetavgbps() 
        {
            System.out.println("Check that getavgbps() return value different from 0");
            Statistics instance = new Statistics(4342342L,
                                                 3231231L,
                                                 3321312L,
                                                 32312313L,
                                                 443422L);
            
            assertThat(instance.getavgbps(), is(not(0L)));
            
            // TODO review the generated test code and remove the default call to fail.
            fail("The test case is a prototype.");
        }

I obtain this ArithmeticExcpetion as the if clause is not present.Junit skip if clause?


Testing using JUnit failed of a class
===

I have this class:

 

    public Statistics(long start_time,
                          long total_hit_count,
                          long emitted_bytes,
                          long idle_threads,
                          long total_threads) 
        {
            this.start_time = start_time;
            
            this.up_time = (System.currentTimeMillis() - start_time) / 1000;
            
            this.total_hit_count = total_hit_count;
            
            this.emitted_bytes = emitted_bytes;
            
            if(this.up_time > 0)
            {
                this.avghit_sec = ((float) this.total_hit_count) / ((float) this.up_time);
            }
            
            if(this.total_hit_count > 0)
            {
                this.avgbytes_hit = this.emitted_bytes / this.total_hit_count;
            }
            
            if(this.up_time > 0)
            {
                this.avgbps = this.emitted_bytes / this.up_time;
            }
            
            this.idle_threads = idle_threads;
            
            this.total_threads = total_threads;
        }

here it is my test class created with Junit.
my purpouse is to test that getavgbpg doesn't return 0 value but I get ArithmeticException even if I have if clause.

    public void testgetavgbps() 
        {
            System.out.println("Check that getavgbps() return value different from 0");
            Statistics instance = new Statistics(4342342L,
                                                 3231231L,
                                                 3321312L,
                                                 32312313L,
                                                 443422L);
            
            assertThat(instance.getavgbps(), is(not(0L)));
            
            // TODO review the generated test code and remove the default call to fail.
            fail("The test case is a prototype.");
        }

I obtain this ArithmeticExcpetion as the if clause is not present.Junit skip if clause?

