Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Tester.java public class Tester { public static void main(String[] args) { int[] a = new int[] { 5, 4, 1, 9, 2, 6 }; Arrays.swapLargestAndSmallest(a);

Tester.java

public class Tester

{

public static void main(String[] args)

{

int[] a = new int[] { 5, 4, 1, 9, 2, 6 };

Arrays.swapLargestAndSmallest(a);

System.out.println(java.util.Arrays.toString(a));

System.out.println("Expected: [5, 4, 9, 1, 2, 6]");

a = new int[] {1, 4, 1, 9, 2, 6};

Arrays.swapLargestAndSmallest(a);

System.out.println(java.util.Arrays.toString(a));

System.out.println("Expected: [9, 4, 1, 1, 2, 6]");

a = new int[] {1, 4, 2, 9, 9, 6};

Arrays.swapLargestAndSmallest(a);

System.out.println(java.util.Arrays.toString(a));

System.out.println("Expected: [9, 4, 2, 1, 9, 6]");

a = new int[] {1};

Arrays.swapLargestAndSmallest(a);

System.out.println(java.util.Arrays.toString(a));

System.out.println("Expected: [1]");

}

}

Convert Tester.java into a JUnit testcase that uses asserts and multiple methods to test each scenario. Shell Junit testcase:

import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class testing { @BeforeAll static void setUpBeforeClass() throws Exception { } @AfterAll static void tearDownAfterClass() throws Exception { } @BeforeEach void setUp() throws Exception { } @AfterEach void tearDown() throws Exception { } @Test void test() { int a = Something.random(); assertEquals(0, a); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions

Question

Non - coding "filler DNA" Your answer

Answered: 1 week ago

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago