lasergame problem with Blankcell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

lasergame problem with Blankcell

Roelof
Hello,

On the first part I have to make a class named BlankCell which is a
subclass of TestCase.
So far no problem.

But when you are on the MirrorCell part BlankCell must be a subclass of
Cell.
But then the tests will fail because should:  cannot be found.

The manual says nothing about that the new class Cell must be a part of
TestCase.

How to solve this ?

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

camille teruel

On 2 avr. 2014, at 13:21, Roelof Wobben <[hidden email]> wrote:

Hello,

On the first part I have to make a class named BlankCell which is a subclass of TestCase.
So far no problem.
But when you are on the MirrorCell part BlankCell must be a subclass of Cell.
But then the tests will fail because should:  cannot be found.

BlankCell is a class of your domain not a test case. I guess the tutorial ask you to create a BlankCellTests test case.
#should is a method of TestCase. Your tests are methods whose names begin with 'test' in subclasses of TestCase.

The manual says nothing about that the new class Cell must be a part of TestCase.
How to solve this ?
Roelof



Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Nicolai Hess
In reply to this post by Roelof
2014-04-02 13:21 GMT+02:00 Roelof Wobben <[hidden email]>:
Hello,

On the first part I have to make a class named BlankCell which is a subclass of TestCase.
So far no problem.

No, firstly, all cells are just subclasses of Object (http://squeak.preeminent.org/tut2007/html/015.html).
class BlankCellTestCase is a subclass of TestCase


 

But when you are on the MirrorCell part BlankCell must be a subclass of Cell.
But then the tests will fail because should:  cannot be found.

In step http://squeak.preeminent.org/tut2007/html/025.html, you create a new abstract class Cell
and moves the BlankCell under the new abstract class.
 


The manual says nothing about that the new class Cell must be a part of TestCase.

No, the TestCases are just "using" your Cell classes.

In http://squeak.preeminent.org/tut2007/html/026.html you are moving the MirrorCell under Cell as well.

And only testcase BlankCellTestCase is a subclass of TestCase.
And then you are createinga new subclass of TestCase -> MirrorCellTestCase

 

How to solve this ?

Roelof



Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Mark Rizun
In reply to this post by Roelof
Hi,

You probably misunderstood the task. 


On the first part I have to make a class named BlankCell which is a subclass of TestCase.
 
You had to create the class BlankCellTestCase (not BlankCell) which is a subclass of TestCase.
BlankCell and BlankCellTestCase are two different classes.
-BlankCell is a class that represents a model of an empty cell (its size, segments etc.)
-BlankCellTestCase is basically a class that helps you to control (and test) methods that you have on BlankCell class.

But when you are on the MirrorCell part BlankCell must be a subclass of Cell.
 
Cell class is an abstract, which is a superclass for following classes: BlankCell, MirrorCell, TargetCell. 
It provides some basic behavior or properties for BlankCell, MirrorCell, TargetCell, which all of them have in common

But then the tests will fail because should:  cannot be found.
 
Sure it fails. in order to use should: the class BlankCellTestCase has to be a subclass of TestCase.
But it is recommended to use assert: instead of should:

The manual says nothing about that the new class Cell must be a part of TestCase.
 
Cell has to be a subclass of an Object.

Cheers,
Mark
 

Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Roelof
In reply to this post by camille teruel
Camille Teruel schreef op 2-4-2014 13:40:

On 2 avr. 2014, at 13:21, Roelof Wobben <[hidden email]> wrote:

Hello,

On the first part I have to make a class named BlankCell which is a subclass of TestCase.
So far no problem.
But when you are on the MirrorCell part BlankCell must be a subclass of Cell.
But then the tests will fail because should:  cannot be found.

BlankCell is a class of your domain not a test case. I guess the tutorial ask you to create a BlankCellTests test case.
#should is a method of TestCase. Your tests are methods whose names begin with 'test' in subclasses of TestCase.


You are right. I m a little bit confused now.

Im now here and on the first test I see a message that it fails on testCellonState. Message not understood should:

Roelof

Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Roelof
In reply to this post by Mark Rizun
Mark Rizun schreef op 2-4-2014 13:51:
Hi,

You probably misunderstood the task. 


On the first part I have to make a class named BlankCell which is a subclass of TestCase.
 
You had to create the class BlankCellTestCase (not BlankCell) which is a subclass of TestCase.
BlankCell and BlankCellTestCase are two different classes.
-BlankCell is a class that represents a model of an empty cell (its size, segments etc.)
-BlankCellTestCase is basically a class that helps you to control (and test) methods that you have on BlankCell class.

But when you are on the MirrorCell part BlankCell must be a subclass of Cell.
 

You are right here.
Cell class is an abstract, which is a superclass for following classes: BlankCell, MirrorCell, TargetCell. 
It provides some basic behavior or properties for BlankCell, MirrorCell, TargetCell, which all of them have in common

But then the tests will fail because should:  cannot be found.
 


I have now these classes :

TestCase subclass: #BlankCellTestCase
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Laser-Game-Tests'

Object subclass: #Cell
    instanceVariableNames: 'activateSegments exitSides'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Laser-Game-Model'

Cell subclass: #BlankCell
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Laser-Game-Model'

And only on this method the test fail on should:

testCellOnState
      | cell |
      cell := BlankCell new.
      cell should: [ cell isOff ].
      cell shouldnt:  [ cell isOn ].


Roelof

Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Mark Rizun
And only on this method the test fail on should:

testCellOnState
      | cell |
      cell := BlankCell new.
      cell should: [ cell isOff ].
      cell shouldnt:  [ cell isOn ].
Yes it does, inasmuch on the bottom of this page ( http://squeak.preeminent.org/tut2007/html/017.html )
both methods return false. I think later the implementation of this two methods will be changed so don't worry.

Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Roelof
Mark Rizun schreef op 2-4-2014 14:22:
And only on this method the test fail on should:

testCellOnState
      | cell |
      cell := BlankCell new.
      cell should: [ cell isOff ].
      cell shouldnt:  [ cell isOn ].
Yes it does, inasmuch on the bottom of this page ( http://squeak.preeminent.org/tut2007/html/017.html )
both methods return false. I think later the implementation of this two methods will be changed so don't worry.


Correct but on this page : http://squeak.preeminent.org/tut2007/html/025.html
some methods are moved to another class.

and then on this page : http://squeak.preeminent.org/tut2007/html/026.html
The first step is to run Test runner and then it fails and only on this test.

Roelof

Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Mark Rizun
Does this test fails to assert something or it throws you some error?


2014-04-02 15:27 GMT+03:00 Roelof Wobben <[hidden email]>:
Mark Rizun schreef op 2-4-2014 14:22:
And only on this method the test fail on should:

testCellOnState
      | cell |
      cell := BlankCell new.
      cell should: [ cell isOff ].
      cell shouldnt:  [ cell isOn ].
Yes it does, inasmuch on the bottom of this page ( http://squeak.preeminent.org/tut2007/html/017.html )
both methods return false. I think later the implementation of this two methods will be changed so don't worry.


Correct but on this page : http://squeak.preeminent.org/tut2007/html/025.html
some methods are moved to another class.

and then on this page : http://squeak.preeminent.org/tut2007/html/026.html
The first step is to run Test runner and then it fails and only on this test.

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Roelof
Mark Rizun schreef op 2-4-2014 14:58:
> Does this test fails to assert something or it throws you some error?
>

Like I said earlier it fails with this message:

MessageNotUnderstood: BlankCell >> should.


Which I find wierd because I use should: also on the other test methods
off BlankCell and not getting this error.

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Mark Rizun
Could you give me the code of test that fails?


2014-04-02 16:05 GMT+03:00 Roelof Wobben <[hidden email]>:
Mark Rizun schreef op 2-4-2014 14:58:

Does this test fails to assert something or it throws you some error?


Like I said earlier it fails with this message:

MessageNotUnderstood: BlankCell >> should.


Which I find wierd because I use should: also on the other test methods off BlankCell and not getting this error.

Roelof



Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Roelof
Mark Rizun schreef op 2-4-2014 15:07:
> Could you give me the code of test that fails?
>
>

I can but I did already.

The code is :

testCellOnState
       | cell |
       cell := BlankCell new.
       cell should: [ cell isOff ].
       cell shouldnt:  [ cell isOn ].

And this is a code which succeeced:

estCellExitSides
      | cell exit |
     cell := BlankCell new.
     exit := cell exitSideFor: #north.
     self should: [ exit = #south ].
     exit := cell exitSideFor: #east.
     self should: [ exit = #west ].
     exit := cell exitSideFor: #south.
     self should: [ exit = #north ].
     exit := cell exitSideFor: #west.
     self should: [ exit = #east ].

Roelof



Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Mark Rizun
The mistake is simple. You have to write as follows (just replace cell for self in two lines before should and shouldnt):

testCellOnState
      | cell |
      cell := BlankCell new.
      self should: [ cell isOff ].
      self shouldnt:  [ cell isOn ].



2014-04-02 16:12 GMT+03:00 Roelof Wobben <[hidden email]>:
Mark Rizun schreef op 2-4-2014 15:07:

Could you give me the code of test that fails?



I can but I did already.

The code is :


testCellOnState
      | cell |
      cell := BlankCell new.
      cell should: [ cell isOff ].
      cell shouldnt:  [ cell isOn ].

And this is a code which succeeced:

estCellExitSides
     | cell exit |
    cell := BlankCell new.
    exit := cell exitSideFor: #north.
    self should: [ exit = #south ].
    exit := cell exitSideFor: #east.
    self should: [ exit = #west ].
    exit := cell exitSideFor: #south.
    self should: [ exit = #north ].
    exit := cell exitSideFor: #west.
    self should: [ exit = #east ].

Roelof




Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Roelof
Mark Rizun schreef op 2-4-2014 15:16:
The mistake is simple. You have to write as follows (just replace cell for self in two lines before should and shouldnt):

testCellOnState
      | cell |
      cell := BlankCell new.
      self should: [ cell isOff ].
      self shouldnt:  [ cell isOn ].



You are abolute right.
Wierd that earlier test succceed where this error also is made.

Roelof

Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

Mark Rizun
That is really wierd:)


2014-04-02 17:17 GMT+03:00 Roelof Wobben <[hidden email]>:
Mark Rizun schreef op 2-4-2014 15:16:
The mistake is simple. You have to write as follows (just replace cell for self in two lines before should and shouldnt):

testCellOnState
      | cell |
      cell := BlankCell new.
      self should: [ cell isOff ].
      self shouldnt:  [ cell isOn ].



You are abolute right.
Wierd that earlier test succceed where this error also is made.

Roelof


Reply | Threaded
Open this post in threaded view
|

Re: lasergame problem with Blankcell

camille teruel

On 2 avr. 2014, at 16:27, Mark Rizun <[hidden email]> wrote:

That is really wierd:)


2014-04-02 17:17 GMT+03:00 Roelof Wobben <[hidden email]>:
Mark Rizun schreef op 2-4-2014 15:16:
The mistake is simple. You have to write as follows (just replace cell for self in two lines before should and shouldnt):

testCellOnState
      | cell |
      cell := BlankCell new.
      self should: [ cell isOff ].
      self shouldnt:  [ cell isOn ].



You are abolute right.
Wierd that earlier test succceed where this error also is made.

It's just because before you were subclassing BlankCell from TestCase so BlankCell instances were answering #should: .


Roelof