How To Build Test Cases So When New Class Is Added It Automatically Gets Tested

Jul 2, 2014

I'm trying to develop a system for test cases so that whenever a test case is added to a particular package it will automatically be included in testing without having to manually add that particular test case.  What is the best way to achieve this?  Should I use java reflection? I'm just getting started with Jenkins and trying to configure Selenium test cases.

View Replies


ADVERTISEMENT

How To Write Test Cases For Void Methods

Mar 19, 2014

I'm trying to write test cases for void methods. Here is my sample code

public void objIntoFile() throws Exception {
addAdminObjects();
file = new File("D:ExtractingDBexport.txt");
writer = new BufferedWriter(new FileWriter(file));

[Code] .....

View Replies View Related

Cipher Code - Encryption Test Cases Not Working

Oct 1, 2014

I have following Cipher Code and test for it. But I am getting following exception.

Java Code:

java.lang.IllegalStateException: Cipher not initialized
at javax.crypto.Cipher.checkCipherState(Cipher.java:1672)
at javax.crypto.Cipher.doFinal(Cipher.java:2079)
at com.anjib.util.CipherUtil.encrypt(CipherUtil.java:67)
at com.anjib.util.CipherTest.testEncryptDecrypt(CipherTest.java:23) mh_sh_highlight_all('java'); Java Code: public class CipherUtil {
private static Logger log = Logger.getLogger(CipherUtil.class);

[Code] ....

View Replies View Related

Methods From Original Class Receiving Error When In Test Class

Jul 5, 2014

I am working on a program that simulates a bug moving along a horizontal line, My code works correctly when I test it in it's own class but when I tried testing my constructor and methods in a test class I received an error saying, "package stinkBug does not exist" on lines with my methods. However, stinkbug is not a package.

Java Code:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

[code]....

View Replies View Related

Swing/AWT/SWT :: Build Code To Call Class As JTree?

Sep 28, 2014

I am trying to make a JTree. I have used this guide :[URL]

Now when I call my Class with

TreeMainMenu tree = new TreeMainMenu();
JScrollPane MainMenu = new JScrollPane(tree);

I get only the default JTree..

I need to understand how I should build my code to call the class as JTree.

This is my code:

public class TreeMainMenu extends JTree {
private DefaultMutableTreeNode top = new DefaultMutableTreeNode("TOP");
JTree tree;
public JTree TreeMainMenu() {
APNode();
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
return tree;

[code]....

View Replies View Related

How To Test If Class / Object Is Immutable

Jul 2, 2014

I have make the immutable class as below, Now my question is how I can test if my this class/object is immutable

package com.learning;
import java.util.*;
import java.util.Map.Entry;
public final class ImmutableTest {
private final int id;
private final String name;
private final HashMap<String, String> hm ;

[Code]...

How I can Test If it is immutable class without looking ?

View Replies View Related

Binary Tree Java Test Class

Mar 24, 2014

So, managed to get my Binary Search Tree to work properly:

package SystemandDesign.BinaryTree;
 import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.io.ObjectInputStream;
import java.util.Scanner;
 
[Code] ....

No matter how many times I keep rewritting the testInsert method I get a chock full of errors.

View Replies View Related

How To Test Default Constructor In Different Class In Java

Nov 5, 2014

How do you test a default constructor in one class and then test it in a different class? This is the code for the Person class which has the default constructor. I'm not sure in the PersonTester class how to access this default constructor and how to test it - what I have so far for the second class is also below.

class Person {
// Data Members
private String name; // The name of this person
private int age; // The age of this person
private char gender; // The gender of this person

[code]...

View Replies View Related

Writing A Test Class Using (invoke) Method

May 4, 2015

I had to write a class called Thermometer, that has one instance variable (an integer) for the temperature in Fahrenheit. I had to include the following methods

-a constructor that initializes the temperature to 60

-there is a method to change the temperature

-there is a method to display the temperature

-there is a method to reset the teperature to 60

Here is the code for that.

public class Thermometer {
private int temp;
private int thermometer;
public Thermometer() {
thermometer = 60;

[code]....

Now I get to the issue. I have to write a test class called thermometer to test the thermometer class. I need to test each method while displaying the temperature after it. My professor said I should use the invoke method but didn't go into much more detail than that.

View Replies View Related

Writing A Program To Test Person Class

Nov 4, 2014

User-defined classes. The concept of getters and setters goes right over my head. Right now we're to write a program to test the Person class below. We have to create 2 instances of the class to test each constructor, and test each method.

class Person {
// Data Members
private String name; // The name of this person
private int age; // The age of this person
private char gender; // The gender of this person
// Default constructor
public Person() {
this("Not Given", 0, 'U');

[code]....

then my output will print out the name. But the assignment doesn't tell us to modify the Person class at all, just to create a tester one.

View Replies View Related

How To Write Driver Class To Test Methods

Apr 13, 2015

I am to create a Array class then create a Driver class (TestArray) to test all the methods in the Array Class. Here's the code i've written for the Array Class. I just nee developing the TestArray class.

import java.util.Scanner;
public class Array
{
Scanner sc = new Scanner(System.in);
private double[] array = new double[];
public void setArray(double[] arr) {

[Code] ...

View Replies View Related

Create Two Instances Of Class And Test Each Of Methods

Nov 1, 2014

How do I use two constructors and I'm having trouble with using char for gender...

Write a program to test the Person class defined below. Your test program should create two instances of the class (each to test a different constructor) and test each of the methods. You are also required to illustrate the error in trying to access private data members from the client class (for clarity temporarily change the private modifier to public and test again). See screenshots below for sample output.

The screen shots are displayed as:

p1 name = Not Given Age = 0 Gender = U
p2 name = Jane Doe Age = 0 Gender = F
p1 name = John Doe Age = 25 Gender = M

and

PersonTester.jave:20: name has private access in Person
System.out.println("p2 name = " + p2.name + "Age = " + p2.age + "Gender = " + p2.gender);
 PersonTester.jave:20: age has private access in Person
System.out.println("p2 name = " + p2.name + "Age = " + p2.age + "Gender = " + p2.gender);
  PersonTester.jave:20: gender has private access in Person
System.out.println("p2 name = " + p2.name + "Age = " + p2.age + "Gender = " + p2.gender);
 
3 errors

Here is the class given :

class Person {
// Data Members
private String name; // The name of this person
private int age; // The age of this person
private char gender; // The gender of this person
 
[Code] .....

View Replies View Related

Test To See If Object Is Instance Of Interface Class

Mar 7, 2015

I am currently trying to use Junit to test a whole bunch of stuff. I almost have full line coverage but I am getting hung up on testing an if statement that consists of whether or not an object is an instance of another class. This class happens to be an interface, and even the object is an interface. Weird I know but I just want to know how to get into that if statement. I realize testing interfaces might be a waste of time but I still really want to know how. Here is an example of what I am trying to test:

Java Code:

if(x instance of y){ //where x and y are both interface objects
doSomething();
} mh_sh_highlight_all('java');

View Replies View Related

How To Write A Client Class To Test Methods For Assignment

Jan 20, 2014

Write a class encapsualting the concept of a course grade, assuming a course grade has the following attributes: a course name and a letter grade. Include a constructor, the accessor and mutator, and methods toString and equals.Write a client class to test all the methods in your class.

package labmodule7num57;
import java.util.*;
public class LabModule7Num57 {
// Constructors//

[code]....

View Replies View Related

JUnit - Test Class Not Found In Selected Project

Jul 21, 2010

I'm trying to write JUnit test but I'm having trouble with the following errors:

"Test class not found in selected project" -> when running AClassTest.java

"Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class" -> when running AClass.java

I have class AClass.java

and class AClassTest.java

They both are in the same package and there is JUnit library

Here's the code:

AClass.java:

Java Code:

public class AClass {
working code is in the last post
} mh_sh_highlight_all('java');
AClassTest.java:

Java Code: public class AClassTest extends TestCase {

working code is in the last post

} mh_sh_highlight_all('java');

View Replies View Related

Unable To Call / Test All Of The 5 Sorting Methods At Same Time In Main Class

Dec 19, 2014

For reference I am programming Java in BlueJ. I am fairly new to the language and I am having trouble with sorting.

I am trying to call / test all of the 5 sorting methods (at the same time) in the main class. To be specific, the sorted list has to technically outputted 5 times.

I figured out how to call / test Quicksort:

Sorting.quickSort(friends, 0, friends.length-1);

But the others are not working correctly. Specifically these:

Sorting.mergeSort(friends, 0, friends.length-1);
Sorting.PbubbleSort(friends, 0, friends.length-1);
Sorting.PinsertionSort(friends, 0, friends.length-1);
Sorting.selectionSort(friends, 0, friends.length-1);

For reference, this is the output when it is not sorted:

Smith, John 610-555-7384
Barnes, Sarah215-555-3827
Riley, Mark 733-555-2969
Getz, Laura 663-555-3984
Smith, Larry464-555-3489
Phelps, Frank322-555-2284
Grant, Marsha243-555-2837

This is the output when it is sorted:

Barnes, Sarah215-555-3827
Getz, Laura 663-555-3984
Grant, Marsha243-555-2837
Phelps, Frank322-555-2284
Riley, Mark 733-555-2969
Smith, John 610-555-7384
Smith, Larry464-555-3489

This is the class Sorting, which I should note is all correct:

public class Sorting{
/**
* Swaps to elements in an array. Used by various sorting algorithms.
*
* @param data the array in which the elements are swapped
* @param index1 the index of the first element to be swapped
* @param index2 the index of the second element to be swapped
*/
private static <T extends Comparable<? super T>> void swap(T[] data,
int index1, int index2){
T temp = data[index1];
data[index1] = data[index2];

[Code]...

This is the Main class in which I am supposed to call the sorting methods, SortPhoneList:

public class SortPhoneList{
/**
* Creates an array of Contact objects, sorts them, then prints
* them.
*/
public static void main (String[] args){
Contact[] friends = new Contact[7];
friends[0] = new Contact ("John", "Smith", "610-555-7384");
friends[1] = new Contact ("Sarah", "Barnes", "215-555-3827");

[Code]...

View Replies View Related

Using Values That Are Set For Cases In The Switch Operator

Mar 23, 2014

I am new to Java and I am trying to use values that are set for cases in the switch operator.

The first menu ask for you to pick a product and each product has a price on it.

The second menu ask you to pick a state with each state having a decimal value on it.

The third is asking you to put the number of cases and each case is 12 items.

A key note to remember is that each part that a person is choosing is on a different instance!

Here is an example of what i am trying to do.

Menu 1: I picked case 1 that is Computer and it is worth 1000
Menu 2: I picked case 1 that is CT and it's tax is 7.5

Third choice: I picked case 1 and that has 12 items

I want the subtotal witch is: (1000 * 12)

Subtotal in this situation is: 120000

Next i need the total value which is based on what state they picked for the tax percent value picked from the state menu case: (12000 * 0.075 + 120000)

Total value is: 129000

I will post the code I have but based on the choices a person makes will determine the values and I need those values set in the cases to put in a math equation. The problem I am having is retrieving these numbers form the cases inside the menu options and they are on a different instance. So How can I do this in Java code?

Here is the code:

This is menu 1

Java Code:

import java.util.*; //scanners and more
class menu{
public void display_menu() {
System.out.println ("Please select your product"); //Gives user direction
System.out.println ( "1)

[Code] .....

View Replies View Related

Too Many Number Of Cases Of Input - Design Pattern?

Apr 16, 2015

For example

Select food;

1. hamburger 2. pizza 3.chicken 4.sandwich .. etc

if I choose hamburger there are choices again

1. big mac 2.Quarter Pounder with Cheese 3.Double Cheeseburger ...etc

If I choose big mac there are choices again!!.

choose the drink you want

1.coke 2.orange juice ..etc

situations like this, what design pattern should I use?

View Replies View Related

Analyzing And Fixing Failed Cases In Stress Testing

Apr 29, 2014

There are few modules in our application whose performance degrade with time when 50-100 simultaneous users are working on them at a given instance.The memory allocations are taken care of to allow maximum data.My issue to where to start finding the root cause.

I am currenlty using JvisualVM for profiling and finding memory leaks..Do i need to Simualte 50-100 virtual users and start finding the memory leaks with JvisualVM or working with a single user would do ?

View Replies View Related

Servlets :: Simple Use Cases To Filter Out Offensive Language From Entered Text?

May 25, 2014

Looking for some simple use cases for servlet filters other than tracking requests ? I was thinking of using a filter to filter out offensive language from entered text. Would that be a good use case ?

View Replies View Related

Servlets :: Login Form - All Attributes Are Null And HTTP Status 404 Error In Some Cases

May 20, 2014

I'm a new Java user and I'm trying to code a simple login page. In first page (NewFile.jsp) users should enter their username and password and should click on "login", or click on "sign up".

1.) If user enters his username and password correctly, a login page (LoginPage.jsp) appears and says "welcome null" but it should show the name of that user instead of null.

2.) In that login page there is an edit button to edit profile information. When I clicked on it, every information is "null" and when I edit them and click on "Submit" button;

HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
GlassFish Server Open Source Edition 3.1.2

that message appears.

3.) If I click on "Sign Up" button at the beginning, a registration jsp (SignUpPage.jsp) appears. After filling up text boxes and clicking on "Submit", same Status 404 screen appears.

I created a mysql database called "loginpage" using xampp. In that database there is a table called "users" and it has un, pass, name, surname, email and degree attributes.

Here is a screenshot of my project explorer:

Here is my code:

1. NewFile.jsp

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

[Code] .....

View Replies View Related

Manifest Not Added To Jar

Apr 26, 2015

I am creating a .jar for a game I made. I'm not using any dev tools, just a DOS console call to java: %~dp0....javajdkinjar.exe -cfmv TheSwarm.jar manifest.txt *

My manifext.txt contains:

Main-Class: Game

But when I compile the jar, its manifest contains:

Manifest-Version: 1.0
Created-By: 1.7.0_01 (Oracle Corporation)

And I get an error about it not finding the main class. Shouldn't my Main-Class setting be added to the jar? I can manually rename it to .zip and edit the Manifest.MF but that is a huge pain when I'm testing the .jar file and regenerating it often.

View Replies View Related

How Can Items Be Added To List

Feb 13, 2014

I have the following code. how can items be added to that list?

private List<IComponentNode> comp;
interface IAAAView {
  // returns component with given code or null
  IComponentNode findComp(String a);
  // returns component with given renderer or null

[Code] .....

View Replies View Related

Does JVM Gets Installed Automatically

Oct 12, 2014

1. Is this the JVM ?
2. If so, it uses Java version 7. Who uses Java 8 ?
3. If we install Netbeans, does the JVM gets installed automatically?

View Replies View Related

Reuse Dynamically Added Controls

Nov 8, 2014

I am trying to create a form where my customer can add some other fields(like: label,textbox), and he need to use that added fields for the next time he open the application...

I would like to know whether it is possible to save dynamically created controls and reuse it again...

View Replies View Related

JSF :: Column Added In ForEach Tag Not Displaying

Nov 4, 2014

I have a ace:dataTable which contains a variable number of columns. For this I use the c:forEach tag. All generated in the c:forEach are not displayed. In the sample, only columnLibelle and columnSum are displayed.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved