tag:blogger.com,1999:blog-8712770457197348465.post1226519814654992079..comments2024-03-18T23:01:42.768-07:00Comments on Javarevisited: How to Create JUnit Tests in Eclipse and NetBeans IDE? Java Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-8712770457197348465.post-68832996224448270242015-04-26T23:24:38.130-07:002015-04-26T23:24:38.130-07:00Hi this is Arnob. I want to know if we will be all...Hi this is Arnob. I want to know if we will be allowed to run JUnit Tests on Eclipse or from command line during java programming interviews??Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-90862330952294754912014-08-19T06:48:02.490-07:002014-08-19T06:48:02.490-07:00do you still get this error after putting package ...do you still get this error after putting package statement?javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-89689653674161547992014-08-19T06:38:52.394-07:002014-08-19T06:38:52.394-07:00Hi Javin, Yes firstly i created class Claculator w...Hi Javin, Yes firstly i created class Claculator with twi method add() and mutiply(), then created JunitTestCase name as calulatorTest inside com.altair.junit.test package, and Run as Junit Test.Getting <br />java.lang.ClassNotFoundException: com.altair.junit.test.CalculatorTest error.Anonymoushttps://www.blogger.com/profile/01201807078890882299noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-44597518575016446022014-08-19T06:00:16.578-07:002014-08-19T06:00:16.578-07:00Hello Vijay, did you created a class called Calcul...Hello Vijay, did you created a class called CalculatorTest? you should run it from there. If you have created this class inside package com.altair.junit.test, make sure you define them using package statement at top of the class as :<br /><br />package com.altair.junit.test<br /><br />class CalculatorTest{<br />...<br />}javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-31727489629327561112014-08-19T05:36:31.435-07:002014-08-19T05:36:31.435-07:00in eclipse after Run as Junit Test, I am getting f...in eclipse after Run as Junit Test, I am getting following error:<br /><br /> java.lang.ClassNotFoundException: com.altair.junit.test.CalculatorTestAnonymoushttps://www.blogger.com/profile/01201807078890882299noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-26513080852376721592014-07-16T09:21:23.085-07:002014-07-16T09:21:23.085-07:00Netbeans example - would the test class go under T...Netbeans example - would the test class go under Test Packages? The imports did not work, package is missing, Though I think its just info that I lack, that is why I came here. Back to the drawing board. Thanks for the info, but may not be enough for the totally ignorant to start with.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-83234229016890294792014-05-04T22:31:12.503-07:002014-05-04T22:31:12.503-07:00Better way to run JUnit test is from package explo...Better way to run JUnit test is from package explorer window, just select a Unit test, right click and say run as JUnit test. You can even run multiple Unit test by either selecting a package or test folder itself, this will run all JUnit test one by one. If your test throws error, just put a breakpoints at the point they are failing to know the root cause of problem. Kristennoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-22675668929385256122014-05-04T22:28:58.552-07:002014-05-04T22:28:58.552-07:00@Anonymous, @Bnktop, I think that's the bug he...@Anonymous, @Bnktop, I think that's the bug he wants to catch you by writing JUnit test, I would say a better example, because once you run that test, it will fail and give you task to find out what is wrong, there you will find that produce should be assigned 1, instead of zero.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-74654228480141020882014-02-02T07:53:54.351-08:002014-02-02T07:53:54.351-08:00Right. In multiply must product = 1Right. In multiply must product = 1Anonymoushttps://www.blogger.com/profile/00578559522707606924noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-45200028354114259252013-11-06T21:11:21.784-08:002013-11-06T21:11:21.784-08:00Should be this.
0*10*20*30 is still a goddamn zero...Should be this.<br />0*10*20*30 is still a goddamn zero.<br /><br /> public int multiply(int... number) {<br /> int product = 1;<br /> for (int i : number) {<br /> product *= i;<br /> }<br /> return product;<br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-44006675224912614982013-06-11T21:31:18.136-07:002013-06-11T21:31:18.136-07:00How to create suite of Unit test in JUnit 4 veriso...How to create suite of Unit test in JUnit 4 verison?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-9866688453239581372013-03-07T03:29:48.750-08:002013-03-07T03:29:48.750-08:00I am looking for a unit test case which tests the ...I am looking for a unit test case which tests the program which is written for reading HTML from any website and save it to any file(.txt).<br />Can you help?Shailesh Jangrahttp://www.studynfun.wordpress.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-22112926468948968622013-03-06T06:14:36.233-08:002013-03-06T06:14:36.233-08:00Not sure if you have intentionally done this to fi...Not sure if you have intentionally done this to find the error in junit test case, but shouldn't product be initialized to 1 instead of 0 in multiply() method ?Hemanthnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-43786902379335957812013-03-04T01:11:59.757-08:002013-03-04T01:11:59.757-08:00Testing with main method is not a bad idea either,...Testing with main method is not a bad idea either, but yes it doesn't tell whether you test is successful or not, until you use assertion provided by JDK.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-88717397360274845052013-03-02T18:47:13.813-08:002013-03-02T18:47:13.813-08:00@Anonymous, good catch :), it should call multiply...@Anonymous, good catch :), it should call multiply method, correct now.Javin @ Java Classloder Workinghttp://javarevisited.blogspot.com/2012/12/how-classloader-works-in-java.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-50470287611421982172013-03-02T12:28:34.659-08:002013-03-02T12:28:34.659-08:00Very interesting articles, I've read them for ...Very interesting articles, I've read them for a while and I've learned a lot of useful things and tricks. <br /><br />I think a mistake has slipped into this one; please check the test for multiply method, is calling the add method instead of multiply.Anonymousnoreply@blogger.com