Hi I have a method that accepts a List<String> param as a parameter. I'm writing a JUnit test which needs to be able to accept the parameters as a String and then it needs converted to a List<String> The JUnit code is: public void testMethodName(String params, String expectedResult){ final String testCollection = instance.MethodName(params); if (null == expectedResult){ assertNull("Should return null for unspecified value", testCollection); } else{ assertEquals("Should return expected value", expectedResult, testCollection); } } public Object[] parametersForTestMappingCollection(){ final List<Object> testCases = new ArrayList<Object>(); testCases.add(JUnitParamsRunner.$("Company Request-Other than Non Payment", "UR")); Its basically to test a hashmap to make sure the key …

Member Avatar
Member Avatar
+0 forum 4

Hey everyone. I was doing a simple test program today that my professor is asking us to do just to test to see if his Ant script works correctly and I came across a problem that is confusing me. My prof wants us (after created all of our homework class files) to create a TestProgram class where, basically like junit, tests our programs with his given input values. Well, I have never worked with args before (I know, depressing) but I gave it a ashot and got this error. TestProgram.java:16: main(java.lang.String[]) in Sum cannot be applied to (java.lang.String) program.main(arg[0]); ^ …

Member Avatar
Member Avatar
+0 forum 4

I am creating a method to multiply 2 polynomial expressions together such that: `3x^5 * 2x^3 = 6x^8` -> Where the coefficients are multiplied and the exponents are added together. My test case for this would look something like the following @Test public void times01() throws TError { assertEquals(Term.Zero, Term.Zero.times(Term.Zero)); } I should also add that `Term.Zero = (0,0)` and `Term.Unit = (1,0)` So anything multiplied by `Term.Zero` is `Term.Zero` and anything multiplied by `Term.Unit` returns itself as `Term.Unit` effectively is 1. public Term times(Term that) throws CoefficientOverflow, ExponentOverflow, NegativeExponent { return null; } This is the `times` method. I'm …

Member Avatar
Member Avatar
+0 forum 7

I have a Java class called Term holding polynomials like below public Term(int c, int e) throws NegativeExponent { if (e < 0) throw new NegativeExponent(); coef = c; expo = (coef == 0) ? 1 : e; } I also have an equals method in the same class like below @Override public boolean equals(Object obj) { } I am stuck with how to code how to compare these 2 Term objects Within my JUnit test file I am using the test below to try and test the equals method static org.junit.Assert.*; import org.junit.Test; public class ConEqTest { private int …

Member Avatar
Member Avatar
+0 forum 4

Hi, I'm new to junit. I want to create test cases for if condition,loops. do we have any guidelines to write test cases for if conditions.Can any1 explain with an example. Thanks in advance. Lavanya

Member Avatar
Member Avatar
+0 forum 2

Hey! **Im here to ask for Your advice.** For a school project we choosed to create a android application that uses a database. As we are thrid year studens we have some experiance. But it is not as notable. We have **seen some**: **Access SQL** only on acess. How to create a **PHP** website using **MYSQL** as **server side** application. I have used **postgres SQL** with **pgAdmin** to develop a java web application as a part job. **Our valus & goals:** -keep it simple. -db must be on server. (to gain some administrative features) -Cover 80% of code with tests …

Member Avatar
Member Avatar
+0 forum 3

I'm trying to create a jUnit test for my EJB's and if my app just contains a few beans everything's all good but as soon as I incorporate JPA and entity-classes my jUnit test blows up. My test fails at ejbContainer = javax.ejb.embeddable.EJBContainer.createEJBContainer(); and the stack trace says the following: > apr 03, 2012 6:28:05 FM org.glassfish.deployment.admin.DeployCommand execute SEVERE: Exception while preparing the app : Invalid resource : robbandsresor__pm com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : robbandsresor__pm I'm using NetBeans 7.1 and GlassFish 3.1.x (and jUnit 4) and this is a simple web application, and my Persistency Unit was created by NetBeans wizard …

Member Avatar
Member Avatar
+0 forum 1

Is as way test out swing components without having to rely on Thread.sleep() to make sure that the components have realized completely. This problem with this approach is that it becomes difficult to guess how long it would take for components to realize under different environments of execution like vnc may take more time than running in on the local machine, hence if less time is set in the test case will fail with assertions in the local machine. More time set will increase the time for executing the test.

Member Avatar
Member Avatar
+0 forum 3

hi could someone help me in giving a tutorial in learning how to write testcases in java. would preffer in netbeans if eclipse dosen't matter, thanks in advance

Member Avatar
Member Avatar
+0 forum 4

I have this code: [CODE] /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package se211.dz14; import java.util.Scanner; /** * * @author Boris */ public class Month { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Please specify the number of times you want to enter a month:"); int times = scan.nextInt(); for (int i = 0; i < times; i++) { System.out.println("Please enter a month number:"); int month = scan.nextInt(); switch (month) { case 1: System.out.println("January"); break; …

Member Avatar
Member Avatar
+0 forum 1

Hi all, ive got a bit of an annoying problem regarding JUnit 4.5. I've created a bunch of unit tests which work properly when I right click the class and press 'Test' (in Netbeans). However, when I right click the whole project and press 'Test', i get a ClassNotFoundException. I checked the classpaths of the classes and the jar file of JUnit is added in all of them :/ This problem all started when I changed the directory for my tests' location - but it doesnt make any sense to me as they work when tested individually! Any suggestions? Thanks

Member Avatar
+0 forum 0

The End.