By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,236 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,236 IT Pros & Developers. It's quick & easy.

How to create parameterized constructor

P: 2
Hi All,

i have a test class.It allows exactly one zero-argument constructor.
i have another performancetest class,in which i have to pass the respective method name for its performance testing.
but for paasing that method name,i have to first intialize it through parameterized constructor.
My test class doesnt allow me to create parameterized constructor.
so,is there any alternative to constructor??
plz reply if anyone has solution..
Thank you...
Mar 3 '12 #1
Share this Question
Share on Google+
4 Replies

P: 13,264
What do you mean by

but for passing that method name,i have to first intialize it through parameterized constructor.
Why do you have to do this? If your class doesn't have a parameterized constructor then you shouldn't have a requirement to create an instance of it through a parameterized constructor.
You can create a new instance using the default constructor through
class.newInstance() but I don't see why passing a method name requires a parameterized constructor call.
Mar 3 '12 #2

P: 2
first of all,thanks for replying too quick.
let me explain.
attached file is the code for performance testing.
in that i hv passed tht "countProjects" method name against which i hv to do perf testing.projectserviceTest is the provided test class.
this is just sample.i hv more methods like that.
whnvr i try to pass tht name as parameter,its gvs me error like "create parameterized constructor to initialize."
but my test class which is provided to me doesnt allow me to do tht.
my work is just to do performance testing.
can i create a method which can work on behalf of the constructor.
or any other alternative???????
Attached Files
File Type: txt perf.txt (1.0 KB, 258 views)
Mar 3 '12 #3

P: 13,264
How do you tell the ProjectServiceTest which class the method is on?
Looks like you need to see the API specs for you ProjectServiceTest to see what it requires for you to use it successfully.
Mar 3 '12 #4

P: 12
i didnt get your question???? can u please elaborate....
Mar 4 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.