Question

Why is it that my program runs fine but when attempting a JUnit test, it fails...

Why is it that my program runs fine but when attempting a JUnit test, it fails all the tests? New to JUnit and wondering how the architecture works.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There are two possibilities:

  1. Your main program is semantically and logically correct but your JUnit test cases are not.
  2. Your main program is logically wrong and your JUnit tests are right.

In the first scenario, you would need to go through your code logic and rewrite them if necessary.

In the second scenario, your test cases seems to be wrong. In that case, try to debug each one of your test case. Look at what the function is returning and what are you testing it against. Accordingly make the changes in the test function to match the expected output and the actual output.

Add a comment
Know the answer?
Add Answer to:
Why is it that my program runs fine but when attempting a JUnit test, it fails...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help in Java network,    I'm trying to pass Junit 4 tests.       my...

    Need help in Java network,    I'm trying to pass Junit 4 tests.       my Code: public Character findIt( String url){        try {               new URL("myurl").toURI();            System.out.println("pass");            } return null;    } Test case:    @Test    public void testForValidOrNot(){               ValidOrNot validOrNot = new ValidOrNot();                       assertEquals( new Character('pass'), validOrNot.findIt( "my url" ) );    Trying to see why...

  • This is my code for a TicTacToe game. However, I don't know how to write JUnit...

    This is my code for a TicTacToe game. However, I don't know how to write JUnit tests. Please help me with my JUnit Tests. I will post below what I have so far. package cs145TicTacToe; import java.util.Scanner; /** * A multiplayer Tic Tac Toe game */ public class TicTacToe {    private char currentPlayer;    private char[][] board;    private char winner;       /**    * Default constructor    * Initializes the board to be 3 by 3 and...

  • Must write in Java - ignore the Junit tests Write a program that works with fractions....

    Must write in Java - ignore the Junit tests Write a program that works with fractions. You are first to implement three methods, each to perform a different calculation on a pair of fractions: subtract, multiply, and divide. For each of these methods, you are supplied two fractions as arguments, each a two-element array (the numerator is at index 0, the denominator is at index 1), and you are to return a resulting, simplified fraction as a new two-element array...

  • Hey! i hit a roadblock in my C# program. I am just wondering how i would...

    Hey! i hit a roadblock in my C# program. I am just wondering how i would search for a set of 9 numbers within an array and have a message box say if it was there or not. I have it where the contents of the txt file is loaded into an array right when the program starts. Any and all help is greatly appreciated :) each number in the txt file is like this 123445567 385910475 938405719 503818405 the...

  • My program works fine with if else conditions but when it is not working when I...

    My program works fine with if else conditions but when it is not working when I try to implement it using a for loop. Can you fix my for loop and please show me how to do this using loops? I would appreciate if you could explain the loop that you are using. /* Programming Challenge: Shipping Charges The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles Shipped 2 kg or...

  • Write a Java application program that plays a number guessing game with the user. In the...

    Write a Java application program that plays a number guessing game with the user. In the starter code that you are given to help you begin the project, you will find the following lines of code: Random generator = args.length == 0 ? new Random() :                    new Random(Integer.parseInt(args[0])); int secret = generator.nextInt(100); You must keep these lines of code in your program. If you delete these lines, or if you change thse lines in any way, then your program...

  • Homework8 Name and types DUE: April ANOVA theory 17, 2019 1) Why can we not do a series of t-test...

    Homework8 Name and types DUE: April ANOVA theory 17, 2019 1) Why can we not do a series of t-tests when comparing more than two groups? 2) For an ANOVA, in English, what is the null hypothesis? The alternative? What would it mean to reject the null? How is this different than when we reject the null in a t test? 3) If I told you I ran a three-way MANCOVA, what could you tell me about my design and...

  • I was wondering if someone could help me with some problems on my test, my teacher...

    I was wondering if someone could help me with some problems on my test, my teacher allows me to correct them then give them back for 1/2 credit. Along with the correct answer for each I'd like to know why the answers are wrong and why the new answer is correct. The questions with a red mark are the incorrect ones. 12 An unknown hydrocarbon compound (containing only hyd own hydrocarbon compound (containing only hydrogen and carbon) was analyzed for...

  • I was wondering if someone could help me with some problems on my test, my teacher...

    I was wondering if someone could help me with some problems on my test, my teacher allows me to correct them then give them back for 1/2 credit. Along with the correct answer for each I'd like to know why the answers are wrong and why the new answer is correct. The questions with a red mark are the incorrect ones. test a de that contains 0.890 g of sulfur. 7. Calculate the mass of silver in a. 1.08 g...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT