Cucumber In Java Through Code Without Using Junit
Sep 2, 2014i want to use cucumber in java through code. previously i have used it with Junit. but now i need to implement it through coding for the purpose of automating.
View Repliesi want to use cucumber in java through code. previously i have used it with Junit. but now i need to implement it through coding for the purpose of automating.
View RepliesI have been designing a music collection application that runs from a database. I now need to develop a junit test to test the application but I am not sure if Junit has anything to work with testing databases. I have been googling on the internet but most of the search results do not really give any good examples that I can easily follow and adapt to my application. I am using only one table and I would like to test INSERT, UPDATE and DELETE actions and I would also like to test a successful connection.
I once found one tutorial which I cannot find any more that had something that retrieves all the data in the database and stores it in a CSV file and the loops through the CSV file to check or update information.
How do you test the events within an inner class using JUnit
// File: : events/SomePanel.java
// Purpose: Show use of named inner class listener.
import javax.swing.*;
import java.awt.event.*;
class SomePanel extends JPanel {
private JButton myGreetingButton = new JButton("Hello");
private JTextField myGreetingField = new JTextField(20);
[Code] .....
Code extract taken from: Java: Inner-class Listeners
Taking the above example, do I need to use myGreetingButton.doClick to trigger this event to test the respective variables/values being used ? Also the Actionlistener inner classes is private so doubt I can access this from JUnit Test class.
I am making some Junit Tests that process some files with a parser and the do some other processes. I already have a loop for processing a whole folder at a time. But I want to know how can I do so that for each file it processes I can generate an individual report.
View Replies View RelatedCan EJB be developed with a Test Driven Development approach? Is that possible with Junit or should it require other tools/frameworks?I am also interested in understanding which mocks should I consider and which part of the IJB code must instead be tested?
View Replies View RelatedI am working on a class project and I have to write the JUnit test for the GUI class ... what I did wrong ... Here is the code for the GUILauncher:
package edu.oakland.production;
import java.awt.*;
import javax.swing.*;
public class GUILauncher{
public static void main(String[] args){
RetrieveWindow gui = new RetrieveWindow();
[Code] .....
First I was using this way how to get connection and all was fine.
con = DriverManager.getConnection("jdbc:derby:memory:datab;create=true");
But now I have to change it to DataSource and how I find out derby had class ClientDataSource for this but for the hell I can't find out how to setup that virtual DB.
ClientDataSource ds = new ClientDataSource();
con = ds.getConnection();
I get an error "ArrayIndexOutOfBounds" in my Junit test on the following method:
public String[] getMACs(String ssid) {
int first = bs.searchFirst(arrayWlanMac, new GetSet(null, ssid, 0, 0),
new ComparatorSSID());
int last = bs.searchLast(arrayWlanSsid, new GetSet(null, ssid, 0, 0),
[Code] ....
The error occurs in the first while loop right in the if condition (if (!arrayWlanSsid[i + 1].getMac().equalsIgnoreCase(arrayWlanSsid[i].getMac())) )
I'm facing a Problem with the JUnit Test for a Fibonacci rabbits sequence. The JUnit Test should test if the function dynFib(int x) completes the calucation in time. The time given is 100ms. The sequence I wanted to be printed is 0 1 1 2 3 4 6 8 11 15 and I got it but the calculation takes more than 100ms. How can I make it calculate faster without using a loop?
I want to do it recursively and dynamically, I kept trying lots of methods but they did not work.
This is my Code:
public class TestFib {
private static int dynFib(int x, Integer[] array) {
array = new Integer[x + 1];
if (x < 0) {
throw new IllegalArgumentException();
[Code] .....
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');
I have JUnit exposure only in writing simple programs. Here I have one of the usecases requirement pupose I am generating data file(s) by Java programming and calling this data by Hashmap. My file containing two columns
(1) TimeStamp
(2) Speed.
The file is tab formatted file. The business requirement is to check wether the first column should not be 00000000000000 or NULL or BLANK. My question is, how do I check the first field in a file contaning valid information in Junit test case?
Sample File: ( - tab delimited)
1421103602000 542
0000000000000 989
<NULL> 000
1421103603000 588
1421103604000 700
Unfortunately, I am unable to send my Java code here, It was giving some error while attaching in this thread.
I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;
[Code] ....
I have wrote this class who read from text line by line and save the words in fileOnTable.. Now i don't know what to read in ReadOffer to save the words in object offers and return this.. One more question.. What JUnit test can write for this code..?
package com.example.crazysellout.UserSide;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
[Code] ....
how do we get the following numbers (1 2 3 5 8 13 21 34 55 89) out of the following code? I can't get my head around this loop....
HTML Code:
public class Fabnoci{
public static void main(String[] args)
{
int n=10,i,f0=1,f1=1,f2=1;
for(i=1;i<=n;i++)
{
f2=f0+f1;
[code]....
i have made a phone directory and i have also maintained a database for this. i want on clicking the next button each row from database table display one by one on the GUI into their relevant text Fields. i have written this code , this code show the last row of the table on single click on next button. i want one by one row on each next button click.
private void next_contactActionPerformed(java.awt.event.ActionE vent evt) {
try {
String Url = "Jdbc:OdbcirDSN";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(Url,"sa","mysql");
String sql = "SELECT * FROM PersonInformation";
PreparedStatement pstmt = con.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR _UPDATABLE);
[code].....
you will be making four variables (2 primitive integers and 2 Account Objects). You will be following the steps detailed below. The challenge is to understand exactly what is happening and why. Start by coding the following two methods in a java file.
Start your main method with four variables: a, b c, d. a and by should be integer data, set them to be the values 10 and 20 respectively. Variables c and d should be Account Objects. The first account © is Ted, has $70,000 as his balance. The second account (d) is Joe, he has only $15,000 as his balance. Their account numbers are up to you to determine.Next, please print out the four variables: a, b, c, and d. Make sure that you label which ones are which. After you print these variables, please pass all four variables to a static method that you will create below. After you finish the method, please print out the four variables again: a, b, c, and d. Just as they were printed before the method.
Static methods: This method can be called whatever you want, however it will be public, static, and void. This method should take in four parameters: w and x which will be integers, then y and z which will be Account Objects.The first thing this method should do is to print out the four variables w, x, y, and z. This should be done in the same manner as you did in the main method. Next, change the first variable (w) to 15. After that, ted bought a new car. He now has only $20,000 in his account. Change the balance of y to be 20,000. Step three is to make a new Account Object named John, he has a balance of $10,000. Assign him to the variable z. Lastly, print all four variables again: w, x, y, and z.
How to call web service from xml to java. I'm just new in using Java.
View Replies View RelatedWe recently upgraded to JDK 8. Since then, a section of code in a jsp file breaks. The code is this:
ArrayList all = new ArrayList();
final List tsd = timeSeriesBean.getTSData();
all.addAll(tsd);
Collections.sort(all, new Comparator() {
public int compare(Object o1, Object o2) {
TSData t1 = (TSData)o1, t2 = (TSData)o2;
int res = t2.getDate().compareTo(t1.getDate());
[code]....
The error message is this:
An error occurred at line: 65 in the jsp file: /TS/VerifyImportTSData.jsp The type new Comparator(){} must implement the inherited abstract method Comparator.thenComparing(Function, Comparator)
64:
65: Collections.sort(all, new Comparator() {
66: public int compare(Object o1, Object o2) {
67: TSData t1 = (TSData)o1, t2 = (TSData)o2;
68: int res = t2.getDate().compareTo(t1.getDate());
just trying to maintain some old java code that I can support until it is rewritten.
I have a new user on my website - it's password protected etc. and I'm just giving them the initial walkthrough. I have a java applet that plots charts and when he goes to this page he gets no chart and at the bottom of the pages there's a bar with the message "Internet Explorer blocked this website from installing an ActiveX control. What's the risk?" and then there's a button to say Install.
I said, it's just for you to permission running the java applet but his IT guy is saying that java doesn't trigger warnings about ActiveX controls so he's nixing the approval.
I have to write Scanner and Parser for the C-Code based on Java and obtain Abstract syntax tree(AST) . I am allowed to use tools like ANTLR, CUP. But i should be able to expand all macros in my code to its basic low level data type like int, boolean and whats the best approach?How to start initially?
View Replies View RelatedI made just a simple hello world class and i can not seam to make eclipse run it in any way not even the console.
View Replies View RelatedIn fact, I'm not yet past that "Hello World" program.I'm following the steps in "Head First: Java" book, and reached that point where one is ready to write his/her 1st Java code. Here's mine:
public class MyFirstApp
{
public static void main (String[] args)
{
System.out.println("I Rule!");
System.out.println("The World!");
}
}
As simple as it should be, and compiles fine producing the correspondent class. But it doesn't run, however, and spits the following execution-time errors:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MyFirstApp : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
[code]...
I need to access a method from a dll in java as below and is giving an error
"Exception in thread "main" java.lang.UnsatisfiedLinkError: Testdll.Decrypt(Ljava/lang/StringLjava/lang/String;
at Testdll.Decrypt(Native Method)
at Testdll.main(Testdll.java:31)
"
I have included the jna-4.0.0.jar and the HashMatchCryptography.dll to the project in eclipe and the java-library-path has the path for the lib
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.*;
import java.lang.*;
[code]...
How can we prevent SQL Injection in Java Code?..is there any Special cases..
View Replies View RelatedMy method below works fine to print a matrix but when it prints every row, it is printing extra 4 white spaces which is not required. How can I delete those extra spaces at the end? when I use
System.out.print((matrix[i][j] + " ").replaceAll("^s+", ""));
It trims every thing including the spaces I needed for my matrix. So where should I put replaceAll("^s+", "") ?
Java Code:
private static void printMatrix(int[][] matrix) {
System.out.println();
System.out.println("Matrix:");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
} mh_sh_highlight_all('java');
Why can't I see the text when I compile the java code?
Java Code:
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
public class WorldTravel {
public static void main (String[] args){
JFrame f = new JFrame("World Travel!");
BG_text p = new BG_text();
[Code] ....