Search Comments and Ratings

go

   
Date File Comment by Comment Rating
27 Oct 2013 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Keith - On my Mac, MATLAB xUnit passes 150 of the 151 test cases in its own test suite. (The one failure seems to be a bad test case.) Use the contact form on my author page (http://www.mathworks.com/matlabcentral/fileexchange/authors/22204) to send me more details about the problem you are experiencing.

Comment only
16 Oct 2013 Image overlay Overlay a binary mask onto an image using a specified color Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Image Analyst, thanks for your comments. I like your suggestion about accepting the output of bwboundaries as the 2nd input argument. I don't really understand your comment about bwperim, though.

Comment only
22 Jul 2013 Image overlay Overlay a binary mask onto an image using a specified color Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Andrew, you'll have to either pad or resize one of the images to match the other size to overlay them using this function. You could also consider using MATLAB graphics transparency features to overlay one image on another.

Comment only
11 Mar 2013 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

David,

You say, "I believe that xUnit creates a new object for each method in that class for testing rather than iterating through the methods of a single (subclassed) TestCase object." That's correct, and that's a classic xUnit design pattern to ensure order independence of individual test methods. See http://martinfowler.com/bliki/JunitNewInstance.html.

Although it's possible to consider adding setup and teardown methods on a TestSuite level, I haven't done so for MATLAB xUnit.

Because of the release of a new unit testing framework in MATLAB itself (in R2013a), I probably will not put further effort into developing my MATLAB xUnit package. If you can upgrade to R2013a, I encourage you to give the new testing framework a try.

Comment only
26 Feb 2013 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Daniel, you are correct.

Comment only
18 Feb 2013 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Michael - no, I don't know anything about that.

Comment only
06 Jul 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Stefan, are you trying to nest your test functions inside the top-level functions? That is not supported.

There should be no problem terminating your functions with "end" as long as you are not trying to nest them.

Comment only
05 Jul 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Chris, the setup and teardown methods are intended to be called for each test case method that is executed. That's the normal xUnit style. It makes the test cases independently executable.

Comment only
17 Apr 2012 Image overlay Overlay a binary mask onto an image using a specified color Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Lasse - thanks, I have uploaded a new version based on your suggestion.

Comment only
09 Mar 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Patrice, it is likely that you have made a coding error of some sort in constructing your test files. That would explain why the test suite appears to be empty. Try placing one of your test files outside of a package and running it directly to see if it does what you expect.

Comment only
09 Mar 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Federico, if you want to use a simple script as a test case you can. Follow the example in exQuickStart.html.

If you want to use subfunctions as multiple test cases in a single file, then you must use the function line at the top of the file because scripts in MATLAB can't contain functions.

Comment only
01 Mar 2012 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Emmet, assertAlmostEqual has been obsolete since version 2.0 of MATLAB xUnit, which was released 2.5 years ago. It has been superseded by assertElementsAlmostEqual and assertVectorsAlmostEqual. The assertAlmostEqual function is only mentioned in the doc in two places: release-history.html, which tells you when it became obsolete, and the main doc page, xunit_product_page.html, which tells you where you can find it if you still need it (in the obsolete folder).

MATLAB xUnit works just fine in R2011a. Try running its own test suite by adding the xunit folder to the path, changing to the tests directory, and typing runtests. 151 test cases execute successfully in R2011a, including a large number of cases testing the subfunction style.

Automatic test case discovery in ordinary functions is difficult to implement because the MATLAB language has barely enough functionality to do it. As you noted, it requires the use of a script and an undocumented variant of which. When a test writer makes a coding error writing test case files, it isn't easy to determine what is wrong with the file other than it errors out when run, or that it doesn't appear to contain any test cases.

But it does work. My own test suite for the MATLAB files in the book Digital Image Processing Using MATLAB is written entirely using subfunction-style tests and MATLAB xUnit.

I suggest that you start with the working example shown in the doc file exSubfunctionTests.html and go from there.

Comment only
20 Dec 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Maddy, I'm sorry, but I am not familiar with the details of deploying applications using the MATLAB Compiler.

Comment only
20 Dec 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Maddy, the directory containing your tests needs to be on the MATLAB path in order for MATLAB to run the test code found in that directory.

Comment only
15 Dec 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Jan, if all the tests are in the same directory, and if you only want to run a subset of the tests, but there's no naming pattern to easily select the desired subset, then ... the only suggestion I can think of is to write a script to automate the tediousness of typing in all the test file names manually.

Comment only
05 Dec 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Jan, write a function to do it. How do you know which test cases should be selected? By some name pattern, or some other criteria?

Comment only
02 Dec 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Jan, try using the static method TestSuite.fromTestCaseClassName().

Comment only
25 Oct 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Dennis, thanks for the suggested fix.

Comment only
21 Oct 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

James, thanks for the suggestion.

Comment only
30 Aug 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Federico - No.

Comment only
14 Jul 2011 TIMEIT Benchmarking Function TIMEIT.M measures the time required to call a user-specified function Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Andy, I don't fully understand your question. What do you mean by "warm in the time," for example? But I would guess that you're looking for something like this:

x = zeros(1024, 1024);
timeit(@() fft2(x))

Comment only
08 Jun 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Matthew, good question. I suggest that you create a "helper" subfunction, something that doesn't begin or end with "test", that creates an object and then does:

myObj.my3Vector = [1 1];

Then you can create a test case that does this:

assertExceptionThrown(@helperFun, 'myClass:3Vec');

Comment only
29 Mar 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Luke, files that begin or end with "[tT]est" are treated as test files. See this doc page: http://www.mathworks.com/matlabcentral/fx_files/22846/11/content/matlab_xunit/doc/html/exTestCaseSearching.html

Comment only
09 Feb 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Daniel, usually this means that one or more test files are incorrectly written, possibly by omitting the output argument "test_suite" from the function definition line. Take a careful look at this doc page and make sure your test files are written as described: http://www.mathworks.com/matlabcentral/fx_files/22846/11/content/matlab_xunit/doc/html/exSubfunctionTests.html

I will see if I can make the harness smarter about recognizing this kind of malformed test file and producing helpful messages.

Comment only
28 Jan 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Andrew, there's no special trick I know about for unit testing private methods.

Comment only
27 Jan 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Andrew, MATLAB xUnit framework code runs in MATLAB with no special scope privileges, so it cannot run private-directory code directly. One possibility is to reorganize your code to put private-directory functions into a package instead. Another possibility is to put a "gateway" function in the directory above the private directory that returns a structure of function handles to the private functions you want to test.

Comment only
27 Jan 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

I am collaborating with Prof. Diane Kelly (Royal Military College, kelly-d@rmc.ca) and Prof. Greg Wilson (University of Toronto, gvwilson@cs.utoronto.ca) on a study to explore how engineers and scientists test their software, and I'd like to invite you to help.

If you use MATLAB xUnit or a similar unit testing framework to test your MATLAB programs, and if you are willing to let us have a look at the tests you have written and the code that they exercise, please get in touch with us by sending e-mail to research@software-carpentry.org.

Ethical guidelines for the study are posted here: http://software-carpentry.org/research/

Thanks for your help!

Comment only
23 Jan 2011 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Andrew, thanks for your comments. Only class methods go into a class folders, so you should definitely move the test files elsewhere.

Comment only
14 Nov 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Thanks, Jeff. I've made a note to update the documentation regarding this point.

Comment only
11 Nov 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Hi Jeff. I would prefer to keep the functional definition for setup and teardown as simple as possible. When I need to return multiple pieces of data from setup, I just bundle all the pieces into a single struct.

Comment only
02 Nov 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Cengiz - No, I haven't done anything with Andrei's suggestion. Your own assert case is already supported by assertElementsAlmostEqual by specifying 'absolute' for the tolerance type.

Comment only
28 Oct 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Michael, the framework doesn't call the stub, your function computeProjectTime does. The framework doesn't have any way to change MATLAB function name resolution rules in order for your function to call something else instead.

Comment only
27 Oct 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Michael, it sounds like providing a test stub for a portion of the system under test is the responsibility of a test writer, not the test harness.

Comment only
22 Oct 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Hi Michael ... I don't know what that means.

Comment only
30 Sep 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Michael - test_suite is a TestSuite object. This is how the framework gathers up all the test cases into one big hierarchical test suite and then runs them all together. Call one of your test files with an output argument to see what this thing looks like.

There's no HTML reporting tool.

Comment only
08 Jul 2010 Upslope area functions Functions for computing and visualizing upslope area, influence map, dependence map Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Bard, I am not doing any active algorithm development in this area right now, and I have no plans to enhance this submission. You might want to take a look at Wolfgang Schwanghart's TopoToolbox: http://physiogeo.unibas.ch/topotoolbox/

Comment only
23 Jun 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

I have submitted an update that corrects the problem with test cases in packages reported Jared Jacobs on June 16, 2010.

Comment only
16 Jun 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

I've submitted new version 3.0.1 to fix the problem with handling TestCase subclasses inside packages. It should show up on the File Exchange in a day or two.

Here's my fix to the methodIsConstructor function inside TestSuite.m:

function result = methodIsConstructor(method)
method_name = method.Name;
if ~isempty(method.DefiningClass.ContainingPackage)
method_name = [method.DefiningClass.ContainingPackage.Name, '.', ...
method_name];
end
result = strcmp(method_name, method.DefiningClass.Name);
end

Comment only
16 Jun 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Jared - sorry about that. I'll work on a fix right away.

Comment only
09 Jun 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

William - Thanks. I'll make the fix.

Comment only
27 Apr 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

David, In principle one could do this by subclassing TestRunMonitor (http://www.mathworks.com/matlabcentral/fx_files/22846/7/content/matlab_xunit/architecture/html/matlab_xunit_architecture.html#6) with something that spits out XML. I skimmed the information available at the link you provided, and it looks to me like the XML output described there is quite extensive and includes a number of elements that don't apply to MATLAB xUnit. Do you have more specific needs or requirements in mind? Drop me a note if so. My contact information is on my MATLAB Central author page.

Comment only
25 Apr 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Nick, thanks for the suggestion. I'll investigate.

Comment only
23 Apr 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Mike - no, that doesn't work right now. I've been asked about it a couple of times, and I intend to do it, but I just haven't had a chance yet.

Comment only
02 Feb 2010 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Arthur,

Thanks for the report. I'll investigate and prepare an update.

Comment only
04 Aug 2009 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Nick, thanks for the error report about assertElementsAlmostEqual and assertVectorsAlmostEqual. I uploaded a new version (2.0.1) today that fixes the problem.

Comment only
04 Aug 2009 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Nick, the behavior with your setupdata function is a feature. See the doc page called "How to Write Tests That Share Common Set-Up Code."

http://www.mathworks.com/matlabcentral/fx_files/22846/6/content/matlab_xunit/doc/html/exTestFixtures.html

Comment only
08 Jun 2009 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Ryan, I decided not to do the sprintf-style conversion specifiers in the assert functions, as least for now. My experience designing syntaxes for MATLAB and toolbox functions makes me shy away from a syntax design with an indefinite set of trailing arguments, as in sprintf. Such a syntax design makes it difficult to expand the syntax to support other options in the future. For now, you can just inline a call to sprintf directly in the call to the assertion functions.

Comment only
06 May 2009 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Ryan and Guido, the Help Browser team has identified the problem and is trying to fix the problem for the next MATLAB release. In the meantime, you can try this workaround: Put the MTEST directory after the MATLAB directories in your path, instead of before them.

Ryan, thanks for the enhancement suggestion. I have received several good suggestions, and I plan to work on an MTEST update soon.

Comment only
23 Apr 2009 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Hi again Guido,

The Help Browser team was able to reproduce the problem you reported, and they are investigating it. I don't know yet if there's a work-around I could apply to the MTEST doc files.

Steve

Comment only
20 Apr 2009 MATLAB xUnit Test Framework MATLAB xUnit is a unit test framework for MATLAB code. Author: Steve Eddins

Steve Eddins (view profile)

Steve Eddins

Steve Eddins (view profile)

Hi Guido,

I have not been able to reproduce the problem using R2009a on my 32-bit WinXP SP3 machine.

Would you please double-check your MATLAB version? I believe the released version was 7.8.0.347, not 7.8.0.324 as you reported.

Thanks,

Steve

Comment only

Contact us