MiniTest test case execution

G

George Thomas

Hi,

I have MiniTest derived class to run the test cases.

Its something as follows

class CustomClass < MiniTest::Unit::TestCase
def test1
end
def test2
end
.....
.....
def testn
end
end

My requirement is that if the logic inside test1 fails , I do not want
to execute other tests. (test2 onwards)

(Calling exit , seem to be exiting from test1 only)

How can I do that?

Regards,
George
 
I

Intransition

Hi,

I have MiniTest derived class to run the test cases.

Its something as follows

class CustomClass < MiniTest::Unit::TestCase
def test1
end
def test2
end
.....
.....
def testn
end
end

My requirement is that if the logic inside test1 fails , I do not want
to execute other tests. (test2 onwards)

(Calling exit , seem to be exiting from test1 only)

How can I do that?

You can't. The order of test execution is not guaranteed.

You might try putting test2+ in a separate file. You might alos just
turn test1 into a conditional and only define test2+ if the condition
passes. e.g.

if test1_condition
def test2
...
 
C

Caleb Clausen

Hi,

I have MiniTest derived class to run the test cases.

Its something as follows

class CustomClass < MiniTest::Unit::TestCase
def test1
end
def test2
end
.....
.....
def testn
end
end

My requirement is that if the logic inside test1 fails , I do not want
to execute other tests. (test2 onwards)

(Calling exit , seem to be exiting from test1 only)

Consider rewriting it like this: rename test1..testn to check1..checkn
and write a toplevel test like this:

def test_all_of_them
test1
test2
..
testn
end
 
G

George Thomas

Thanks for the reply.

I have found somewhere else in the forum that I can call a single test
case
as

Ruby <rb file name> --name test1

I will call , this from a batch file and store my info. in to a temp.
text file (whether to call the rb file again without the --name argument
or not)

I think the suggested solution by Caleb , is probably not suitable for
me ,as I call assert from many of my test cases.
 
C

Caleb Clausen

I think the suggested solution by Caleb , is probably not suitable for
me ,as I call assert from many of my test cases.

And why does that matter? #assert is a method of TestCase, so it can
be called from any other method of TestCase with no problem. You don't
have to always call it in methods whose names begin with 'test_'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top