i am trying to create a testsuite for an application wherein I have created an abstract class as Test, which has an abstract method ExecuteTest()
This(abstract class Test) is extended by various tests to and ExecuteTest Is overridden to desired test
Now the issue is, i have numerous tests, which I feel can be combined.
The code looks like:
abstract class Test
{
public abstract ExecuteTest()
}
class TestScenario1:Test
{
override ExecuteTest()
{
common part A
code for test scenario 1
common part B
As you can see, i am have many classes(which represents TestScenarios)...
is there a better way to do this?
i am not sure if i can use delegates, as it would required all my methods to have same signature, whereas my caller, 'code for test scenario' has different signatures
also, i did the above because i created a TestPipeline, so i could add my tests as required, Looks like List<Test> pipeline=new Test{new TestScenario1(),TestScenario2()} foreach(Test test in pipeline) test.ExecuteTest()
@MainMa: I wouldn't do that. It makes no sense to answer an off-topic question, on the off-chance that it might actually get migrated to the correct one. Most off-topic questions on Programmers get closed, not migrated. — Robert Harvey ♦40 secs ago
@RonakAgrawal so is there a reason you're reinventing the wheel for testing?
I know you've already invested some time into it since this isn't the first time you've asked about it, but I'm not sure you ever explained why you were trying to recreate a test running suite
"Unit" test is a pretty horrible name. A method can be a unit. So can a class. Or a small number of closely related classes. Or a package. Or a library or application. I've been being philosophical and playing with jUnit to test an entire application by invoking a Main method with given arguments. However, main[] in Java is void and I haven't gotten over not being able to check return values. I'm sure there's a good way, though.
okay, a little more info, i have a performance data collector that logs the performance of the application that i am testing so my Test class has a data structure that holds this data; also there are parameters which define whether to upload logs or not
thats the reason i have a 'Test' class of my own, which is more inclined to application, rather in general sense of 'Test'
@RobertHarvey: notice that I was among the persons who voted to migrate the question to StackOverflow. This being said, the fact that the question is off-topic on a site shouldn't prevent a user from answering the question even before it is migrated to the appropriate SE site. — MainMa45 mins ago
wrapped inside a class, because i cant figure out how to do when i have a list of methods, say M foreach method in MethodList CommonStepA method CommonStepB
class a {
method1(String s) {
//Do Stuff
}
method2(String s) {
//Do other stuff
}
}
class testA {
@before
setup() {
// Setup your test somehow
}
@after
cleanup() {
// Clean up the mess your test made
}
@test
testMethod1() {
// Make sure this method works!
}
@test
testMethod2(){
// Make sure this method works!
}
}
so with that example, thats all the code you would write
(depending on your chosen framework)
but it finds testMethod1 and testMethod2 on it's own, then it runs them, and reports failures and performance
if you have a hard time fitting your code tests into this kind of a format, I would hazard a guess that your code needs refactoring, rather than a different test suite.
the test suites normally just want a function to run, you can stuff whatever you want into that function, including iterating a million times and taking the average or whatever else you want to do for optimally accurate perf data
like my flow is, Startperf,LaunchApp,StopPerf; StartPerf,Login,StopPerf StartPerf,ClickButton1,StopPerf StartPerf,ClickButton2,StopPerf StartPerf,ClickButton1Again,StopPerf
class a {
login(String s) {
//Do Stuff
}
clickButtonOne(String s) {
//Do other stuff
}
}
class testA {
@before
setup() {
// Setup your test somehow
}
@after
cleanup() {
// Clean up the mess your test made
}
@test
testOne() {
// Make sure this method works!
startPerfTimer()
login()
stopPerfTimer()
startPerfTimer()
clickButtonOne()
stopPerfTimer()
// Do other stuff
}
startPerfTimer() {
}
stopPerfTimer() {
}
that's kind of an example of what you could do
again, this is isn't best practice, but I'd still argue that it's better than writing a test automation suite from scratch
another thing of note, both your "pipelineOne" and "pipelineTwo" are measuring the performance of login - that should really just be tested and measured once, in one place
its like, one block gives performance of only one unit; no more, no lesss now , i just have to place these blocks in required order to check different scenarios
class testLogin {
Server s;
@before
setup() {
// Initialize your server
s = new Server();
}
@after
cleanup() {
// Delete your previous server
s = null;
}
@test
testFreshServer() {
startPerfTimer()
login()
stopPerfTimer()
}
testNotFreshServer() {
login()
logout()
startPerfTimer()
login()
stopPerfTimer()
}
}
class testButtonOne {
Server s;
@before
setup() {
s = new server()
// We no longer care about the performance of login! It's already tested and measured!
Suppose Mario is walking on the surface of a planet. If he starts walking from a known location, in a fixed direction, for a predetermined distance, how quickly can we determine where he will stop?
More formally, suppose we are given a convex polytope $P$ in 3-space, a starting point $s$ on t...
Say you have a choice of inheritance or not.. You could create an Animal class and then subclases with a bark method. so a Cat class, a Dog class, and Dog dog = new Dog(); dog.bark(); and it displays woof. Or, you could have just an animal class, it has a field for type of animal, and you set that, and when you set the animal.type, and do animal.bark(); it does the right bark. So, when is it better to use that, or when is it better to use inheritance?
also, is that question is too subjective for the main QnA site?
@barlop imo it's too broad, the serious answer to that is "nobody ever writes code like dog.bark();, show us what you're really working on" and only when we see what you're actually trying to accomplish can we tell if inheritance is a good fit
hello .. please i need help ... i need can protocol library api for stm32f discovery board .and i have no idea .. i wasted 2 days of googling and still dont know what to do ... please please help me
it looks like there are 17 active STM32F discovery boards
looked at a few and the chips don't provide native CAN support - meaning you're going to have to do the low level wiring yourself, which is a serious PITA
is this for a class or a job?
@Ixrec @ThomasOwens CAN is just another protocol like I2C or Serial for embedded systems. CAN just happens to be used a lot in automotive and industrial spaces
it's a very robust protocol, which is why people like it
A Controller Area Network (CAN bus) is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other in applications without a host computer. It is a message-based protocol, designed originally for multiplex electrical wiring within automobiles, but is also used in many other contexts.
Development of the CAN bus started in 1983 at Robert Bosch GmbH. The protocol was officially released in 1986 at the Society of Automotive Engineers (SAE) conference in Detroit, Michigan. The first CAN controller chips, produced by Intel and Philips, came on the market in 1987...
The spec is on wikipedia
heh, if poor @user143252 has to implement that by hand he's so screwed.
I'm guessing this is for a class, in which case he probably has one of the chips with the CAN bus built in, and all he needs to do is configure the right registers and allocate a buffer for in and out messages
this is my project for diploma course .. and i have no idea how to deal with it.... i dont know how to implement the api for can , i already gone thorough the example code ... please guide me ... :(
It probably depends on how the load balancer is written - at what layer it's working at. If it just forwards along the connection, then you might see the internal server. If it intercepts the connection and responds, you might not.
Reading the literature of DDD I came up with the following layers:
Application Outsider World (Controllers, Crons, etc)
Application Services (or UseCases) - which orchestrates multiple Domain Services or Infrastructure Services. They are called from Outside World. They know what things have to ...
Your real challenges in software development are not going to be people who forgot to take their sandwich to work with them. Stop listening to those people and decide for yourself whether it is something you like or not.
I have flexible hours, plenty of vacation time, sick days, pension, insurance, health plans, a very competent and understanding manager, challenging and interesting work that I'm given a great deal of autonomy in approaching, lots of perfectly competent and amiable coworkers...really, there's nothing hellish about it at all
I might have lucked out a bit but there are good programming jobs in the world
especially if you're any good at it
whether you personally enjoy programming is the bigger question frankly
This question may be a better fit on programmers.stackexchange.com - read their help page before posting it there though, and if you do post there, delete this question so you're not "cross-posting". — Blorgbeard55 secs ago