title: Junit - Testing constructor without parameters?
body: <p>I have to create <code>JUnit</code> test cases for this class. One of the tests is to test the constructor of the <code>ShannonsTheorem</code> class. Are there ways to test a constructor that does not have any parameters?</p>
  
  <p>There is another class named <code>ShannonsModel</code> that also needs to have its constructor tested. According to the UML we were provided there are no parameters on that constructor either.</p>
  
  <p>Thanks!</p>
  
  <pre><code>package network;
  import java.util.InputMismatchException;
  import java.util.Scanner;
  
  public class ShannonsTheorem {
  
      ShannonsModel model = new ShannonsModel();
      Scanner kb = new Scanner(System.in);
  
      /**
       * default constructor for ShannonsTheorem class.
       * 
       */
      public ShannonsTheorem()
      {
  
      }
  
      /**
       * Method to return the value in bandwidth variable.
       * @return
       */
      public double getBandwidth()
      {
          return model.getBandwidth();
      }
  
      /**
       * getSignalToNoise method to return the signalToNoise value in variable signalToNoise
       * @return
       */
      public double getSignalToNoise()
      {
          return model.getSignalToNoise();
      }
  
      /**
       * main method for ShannonsTheorem
       * @param args
       * while loop to handle user input to continue or end program
       */
      public static void main(String[] args) 
      {
          try {
  
              Scanner kb = new Scanner(System.in);
  
              Scanner scan = new Scanner(System.in);
              boolean stop = false;    
              while(!stop) { 
  
                  ShannonsTheorem ST = new ShannonsTheorem();
  
  
                  System.out.println("Enter bandwidth in hertz:");
                  ST.setBandwidth(kb.nextDouble());
                  System.out.println("Enter signalToNoise:");
                  ST.setSignalToNoise(kb.nextDouble());
  
                  System.out.println("Values are:");
                  System.out.println("Bandwidth"); 
                  System.out.println(ST.getBandwidth());
                  System.out.println("SignalToNoise:"); 
                  System.out.println(ST.getSignalToNoise());
                  System.out.println(ST.maxiumumDataRate());
  
  
                  System.out.println("Press any key to make another calculation.  Type N or n to Quit");
                  String s = scan.nextLine();
                  if(s.equals("n") || s.equals("N")) {
                      stop = true;
                  } // end of if
              } // end of while loop
  
          }catch (InputMismatchException e){
  
              System.out.println("Input Exception was caught, restart program");
  
          }catch(NumberFormatException e){
  
              System.out.println("Format Exception was caught, restart program");
  
          }   
      }
  
      /**
       * public method to retrieve the maximum data rate. This method makes a call to the private method 
       * under the same name.
       * @return
       */
      public double maxiumumDataRate()
      {
          // calling to the private method maxiumumDataRate. Storing the return value from said method into variable result
          // when this public method is called it will return the result from the private method, 
          double result = model.maxiumumDataRate();
          System.out.print(model.toString());
  
          return result;
      }
  
      /**
       * setBandwidth method to set the bandwidth value in hertz
       * @param h
       */
      public void setBandwidth(double h)
      {
          model.setBandwidth(h);
      }
  
      /**
       * setSignalToNoise method to set the signalToNoise variable
       * @param snr
       */
      public void setSignalToNoise(double snr)
      {
          model.setSignalToNoise(snr);
      }
  }
  </code></pre>