English 中文(简体)
Migrating from SUnit to Phexample
原标题:

I m trying out Pharo s Phexample and I like it, but it feels clumsy to have half my unit tests in SUnit and the other half in Phexample. Does Phexample have like an import feature for my existing tests?

问题回答

Concerning the expectation matchers, there is a series of rewrite rules on the class side of PhexMatcher. This screencast explains how to use RB s rewrite engine: Code Critics in OB (OB Screencast 3).

First use these rules

RBParseTreeRewriter new
    replace:  self assert: [ `@expression ]  with:  self assert: `@expression ;
    replace:  self deny: `@expression  with:  self assert: `@expression not ;
    yourself.

Then use these rules

RBParseTreeRewriter new
    replace:  self assert: `@value = `@expected  with:  `@value should = `@expected ;
    replace:  self assert: `@value ~= `@expected  with:  `@value should not = `@expected ;
    replace:  self assert: `@value > `@expected  with:  `@value should > `@expected ;
    replace:  self assert: `@value < `@expected  with:  `@value should < `@expected ;
    replace:  self assert: `@value >= `@expected  with:  `@value should >= `@expected ;
    replace:  self assert: `@value <= `@expected  with:  `@value should <= `@expected ;
    replace:  self assert: (`@value isKindOf: `@type)  with:  `@value should beKindOf: `@type ;
    replace:  self assert: `@expression isNil  with:  `@expression should be isNil ;
    replace:  self assert: `@expression notNil  with:  `@expression should be notNil ;
    replace:  self assert: `@expression `test not  with:  `@expression should not be `test 
        when: [:node | node arguments first receiver selector matchesRegex:  (is|has|not).+|atEnd  ];
    replace:  self assert: `@expression `test  with:  `@expression should be `test 
        when: [:node | node arguments first selector matchesRegex:  (is|has|not).+|atEnd  ];
    replace:  self assert: (`@collection includes: `@element) not  with:  `@collection should not be includes: `@element ;
    replace:  self assert: (`@collection includes: `@element)  with:  `@collection should be includes: `@element ;
    yourself.

Concerning the introduction of dependencies between test, you have to rewrite your tests by Hand. For JExample there is JUnit2JExample but alas there is not automagic migration for Smalltalk (yet).


PS: if you are using the latest Pharo image you must use OB and revert the OB-Refactory package to get scoped rewrite rules working. Just execute

SystemBrowser default: OBSystemBrowserAdaptor.
Gofer new
    wiresong:  ob ;
    addPackage:  OB-Refactory ;
    revert




相关问题
run unit tests and coverage in certain python structure

I have some funny noob problem. I try to run unit tests from commandline: H:PROpyEstimator>python src estpython est_power_estimator.py Traceback (most recent call last): File "src est...

How to unit-test an enterprise symfony project?

I´m working on a huge project at my work. We have about 200 database tables, accordingly a huge number of Models, Actions and so on. How should I begin to write tests for this? My biggest problem ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Unit testing. File structure

I have a C++ legacy codebase with 10-15 applications, all sharing several components. While setting up unittests for both shared components and for applications themselves, I was wondering if there ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签