{"id":8880,"date":"2017-10-06T10:26:08","date_gmt":"2017-10-06T14:26:08","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8880"},"modified":"2017-10-06T10:29:01","modified_gmt":"2017-10-06T14:29:01","slug":"mockobject","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/10\/06\/mockobject\/","title":{"rendered":"MockObject"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42959-mockobject\">Mock Object<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1380672\">Paul Sexton<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<p>Paul has provided a mock object that is useful for mocking inaccessible or slow software or hardware while executing unit<br \/>\n      tests.  Paul&#8217;s <tt>MockObject<\/tt> allows for adding methods, and output assignment (based on a call stack), and stores how it was used for later qualification.<br \/>\n       I also like how he&#8217;s provided an example that shows the real software he&#8217;s testing and the mock object that mocks it.\n   <\/p>\n<p>In R2017a, MATLAB came out with a <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/mocking-framework.html\">native mocking framework<\/a>.  It is used a little differently in that when you create a mock you get two objects back, a mock instance and a behavior<br \/>\n      object for the mock.  You then modify the behavior to tune how the mock object will behave.\n   <\/p>\n<p>I&#8217;ve recently been using the MATLAB mocking framework for the purpose of mocking a database connection.  Here&#8217;s what I&#8217;ve<br \/>\n      done for one of the tests, albeit mine is inside of a unit test class that inherits from <tt>matlab.mock.TestCase<\/tt>. I&#8217;m testing that the <i>LastUpdateTime<\/i> property of my class updates correctly when data are added to the various tables in the database.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">testCase = matlab.mock.TestCase.forInteractiveUse;\r\n\r\nimport <span style=\"color: #A020F0\">matlab.mock.actions.AssignOutputs<\/span>;\r\nimport <span style=\"color: #A020F0\">matlab.mock.constraints.WasCalled<\/span>;\r\nimport <span style=\"color: #A020F0\">matlab.mock.actions.ThrowException<\/span>;<\/pre>\n<p>Mock the <a href=\"https:\/\/www.mathworks.com\/help\/database\/ug\/database.html\">database<\/a> and the <a title=\"https:\/\/www.mathworks.com\/help\/database\/ug\/cursor.html (link no longer works)\">cursor<\/a>.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Mock the database and the cursor<\/span>\r\n[dbmock, dbbehavior] = createMock(testCase, <span style=\"color: #A020F0\">'AddedMethods'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n    {<span style=\"color: #A020F0\">'isa'<\/span>, <span style=\"color: #A020F0\">'isopen'<\/span>, <span style=\"color: #A020F0\">'insert'<\/span>, <span style=\"color: #A020F0\">'update'<\/span>, <span style=\"color: #A020F0\">'exec'<\/span>});\r\n[cursmock, cursbehavior] = createMock(testCase, <span style=\"color: #A020F0\">'AddedMethods'<\/span>, <span style=\"color: #0000FF\">...<\/span>\r\n    {<span style=\"color: #A020F0\">'close'<\/span>, <span style=\"color: #A020F0\">'fetch'<\/span>}, <span style=\"color: #A020F0\">'AddedProperties'<\/span>,{<span style=\"color: #A020F0\">'Data'<\/span>});<\/pre>\n<p>Define the behavior of cursor and database connection.  Note that these read like English sentences.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Pass the validation tests<\/span>\r\nwhen(withAnyInputs(dbbehavior.isa), AssignOutputs(<span style=\"color: #A020F0\">'database.jdbc.connection'<\/span>));\r\nwhen(withAnyInputs(dbbehavior.isopen), AssignOutputs(true));\r\n\r\n<span style=\"color: #228B22\">% Return cursor mock when database or cursor are executed\/fetched.<\/span>\r\nwhen(withAnyInputs(dbbehavior.exec), AssignOutputs(cursmock));\r\nwhen(withAnyInputs(cursbehavior.fetch), AssignOutputs(cursmock));<\/pre>\n<p>We need to build data that looks like what is required.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Synthetic output times that mimic expectation of multiple hits to a<\/span>\r\n<span style=\"color: #228B22\">% database.<\/span>\r\nnowish = datetime(<span style=\"color: #A020F0\">'now'<\/span>, <span style=\"color: #A020F0\">'TimeZone'<\/span>, <span style=\"color: #A020F0\">'America\/New_York'<\/span>);\r\nt1 = table([nowish; nowish],  {<span style=\"color: #A020F0\">'Weather'<\/span>; <span style=\"color: #A020F0\">'Energy'<\/span>}, <span style=\"color: #A020F0\">'VariableNames'<\/span>, {<span style=\"color: #A020F0\">'lastModified'<\/span>, <span style=\"color: #A020F0\">'tableType'<\/span>})\r\nt2 = t1;\r\nt2.lastModified(1) = t2.lastModified(1)+seconds(1); <span style=\"color: #228B22\">% Just Weather<\/span>\r\nt3 = t2;\r\nt3.lastModified(2) = t3.lastModified(2)+seconds(3); <span style=\"color: #228B22\">% Just Energy<\/span>\r\n\r\n<span style=\"color: #228B22\">% Build table to insert in the format MySQL requires<\/span>\r\nc = {<span style=\"color: #A020F0\">'01-May-2007 00:00:00'<\/span>,4854.40000000000,58,30;<span style=\"color: #A020F0\">'01-May-2007 00:05:00'<\/span>,4802.30000000000,58.0833333333333,29.8333333333333;<span style=\"color: #A020F0\">'01-May-2007 00:10:00'<\/span>,4740.30000000000,58.1666666666667,29.6666666666667;<span style=\"color: #A020F0\">'01-May-2007 00:15:00'<\/span>,4700.34155844156,58.2500000000000,29.5000000000000;<span style=\"color: #A020F0\">'01-May-2007 00:20:00'<\/span>,4681.77969924812,58.3333333333333,29.3333333333333;<span style=\"color: #A020F0\">'01-May-2007 00:25:00'<\/span>,4648.99421487603,58.4166666666667,29.1666666666667;<span style=\"color: #A020F0\">'01-May-2007 00:30:00'<\/span>,4633.70864197531,58.5000000000000,29};\r\ndata = cell2table(c, <span style=\"color: #A020F0\">'VariableNames'<\/span>, {<span style=\"color: #A020F0\">'Time'<\/span>, <span style=\"color: #A020F0\">'N_Y_C_'<\/span>, <span style=\"color: #A020F0\">'TemperatureF_KLGA'<\/span>, <span style=\"color: #A020F0\">'Dewpoint_KLGA'<\/span>});\r\ndata.Time = datetime(data.Time);\r\ndata.KLGA = [data.TemperatureF_KLGA data.Dewpoint_KLGA];\r\ndata.TemperatureF_KLGA = [];\r\ndata.Dewpoint_KLGA = [];\r\ndata = table2timetable(data)<\/pre>\n<pre style=\"font-style:oblique\">t1 =\r\n  2&times;2 table\r\n        lastModified        tableType\r\n    ____________________    _________\r\n    06-Oct-2017 10:22:12    'Weather'\r\n    06-Oct-2017 10:22:12    'Energy' \r\ndata =\r\n  7&times;2 timetable\r\n            Time            N_Y_C_          KLGA      \r\n    ____________________    ______    ________________\r\n    01-May-2007 00:00:00    4854.4        58        30\r\n    01-May-2007 00:05:00    4802.3    58.083    29.833\r\n    01-May-2007 00:10:00    4740.3    58.167    29.667\r\n    01-May-2007 00:15:00    4700.3     58.25      29.5\r\n    01-May-2007 00:20:00    4681.8    58.333    29.333\r\n    01-May-2007 00:25:00      4649    58.417    29.167\r\n    01-May-2007 00:30:00    4633.7      58.5        29\r\n<\/pre>\n<p>Set up outputs for the Data property.  Error after three uses.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">when(get(cursbehavior.Data), <span style=\"color: #0000FF\">...<\/span>\r\n    then(repeat(1, AssignOutputs(t1)), <span style=\"color: #0000FF\">...<\/span>\r\n    then(repeat(1, AssignOutputs(t2)), <span style=\"color: #0000FF\">...<\/span>\r\n    then(repeat(1, AssignOutputs(t3)), ThrowException))));<\/pre>\n<p>Exercise the system.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Build DatabaseHandler<\/span>\r\ndb = DatabaseHandler(dbmock);\r\n\r\n<span style=\"color: #228B22\">% Add energy and weather (both database tables)<\/span>\r\naddData(db, data);<\/pre>\n<p>Qualify database called properly and that <i>LastUpdateTime<\/i> property updates correctly.  Add a 1 second buffer for processing time.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">testCase.verifyThat(withAnyInputs(dbbehavior.insert()), WasCalled(<span style=\"color: #A020F0\">'WithCount'<\/span>, 2));\r\ntestCase.verifyThat(withAnyInputs(dbbehavior.update()), WasCalled(<span style=\"color: #A020F0\">'WithCount'<\/span>, 2));\r\nfirstlut = db.LastUpdateTime;\r\nnowish = datetime(<span style=\"color: #A020F0\">'now'<\/span>, <span style=\"color: #A020F0\">'TimeZone'<\/span>, <span style=\"color: #A020F0\">'America\/New_York'<\/span>)+seconds(1);\r\ntestCase.verifyLessThan(table2array(firstlut), nowish);<\/pre>\n<pre style=\"font-style:oblique\">Interactive verification passed.\r\nInteractive verification passed.\r\nInteractive verification passed.\r\n<\/pre>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Add just weather (just weather table in database)<\/span>\r\naddData(db, data(:, {<span style=\"color: #A020F0\">'KLGA'<\/span>}));\r\ntestCase.verifyThat(withAnyInputs(dbbehavior.insert()), WasCalled(<span style=\"color: #A020F0\">'WithCount'<\/span>, 3));\r\ntestCase.verifyThat(withAnyInputs(dbbehavior.update()), WasCalled(<span style=\"color: #A020F0\">'WithCount'<\/span>, 3));\r\nsecondlut = db.LastUpdateTime;\r\ntestCase.verifyEqual(secondlut.Energy, firstlut.Energy);\r\ntestCase.verifyGreaterThan(secondlut.Weather, firstlut.Weather);<\/pre>\n<pre style=\"font-style:oblique\">Interactive verification passed.\r\nInteractive verification passed.\r\nInteractive verification passed.\r\nInteractive verification passed.\r\n<\/pre>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Add just energy (just energy table in database)<\/span>\r\naddData(db, data(:, {<span style=\"color: #A020F0\">'N_Y_C_'<\/span>}));\r\ntestCase.verifyThat(withAnyInputs(dbbehavior.insert()), WasCalled(<span style=\"color: #A020F0\">'WithCount'<\/span>, 4));\r\ntestCase.verifyThat(withAnyInputs(dbbehavior.update()), WasCalled(<span style=\"color: #A020F0\">'WithCount'<\/span>, 4));\r\nthirdlut = db.LastUpdateTime;\r\ntestCase.verifyEqual(secondlut.Weather, thirdlut.Weather);\r\ntestCase.verifyGreaterThan(thirdlut.Energy, secondlut.Energy);<\/pre>\n<pre style=\"font-style:oblique\">Interactive verification passed.\r\nInteractive verification passed.\r\nInteractive verification passed.\r\nInteractive verification passed.\r\n<\/pre>\n<p>Going forward, I&#8217;d recommend using the MATLAB testing frameworks for your testing needs.  They&#8217;re an area of MATLAB that has<br \/>\n      really matured quite well over the last few years.  If you need to design for older releases, then Paul&#8217;s <tt>MockObject<\/tt> can certainly help.\n   <\/p>\n<p>For another blog post on the MATLAB Mocking Framework, see this <a href=\"https:\/\/blogs.mathworks.com\/developer\/2017\/07\/06\/dont-mock-me\/\">blog post<\/a> on the Developer Blog.\n   <\/p>\n<h3>Comments<a name=\"12\"><\/a><\/h3>\n<p>Give both mocking frameworks a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8880#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42959-mockobject#comments\">comment<\/a> for Paul.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_84b0e2ad3c494c7abd40c840c4b7d136() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='84b0e2ad3c494c7abd40c840c4b7d136 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 84b0e2ad3c494c7abd40c840c4b7d136';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_84b0e2ad3c494c7abd40c840c4b7d136()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2017b<\/p>\n<\/div>\n<p><!--\n84b0e2ad3c494c7abd40c840c4b7d136 ##### SOURCE BEGIN #####\n%% Mock Object\n%\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42959-mockobject Mock Object> by\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1380672 Paul Sexton>.\n% \n\n%% \n% Paul has provided a mock object that is useful for mocking inaccessible\n% or slow software or hardware while executing unit tests.  Paul's\n% |MockObject| allows for adding methods, and output assignment (based on a\n% call stack), and stores how it was used for later qualification.  I also\n% like how he's provided an example that shows the real software he's\n% testing and the mock object that mocks it.\n%\n% In R2017a, MATLAB came out with a\n% <https:\/\/www.mathworks.com\/help\/matlab\/mocking-framework.html native\n% mocking framework>.  It is used a little differently in that when you\n% create a mock you get two objects back, a mock instance and a behavior\n% object for the mock.  You then modify the behavior to tune how the mock\n% object will behave.\n% \n% I've recently been using the MATLAB mocking framework for the purpose of mocking\n% a database connection.  Here's what I've done for one of the tests, albeit mine is\n% inside of a unit test class that inherits from |matlab.mock.TestCase|.\n% I'm testing that the _LastUpdateTime_ property of my class updates\n% correctly when data are added to the various tables in the database.\n\ntestCase = matlab.mock.TestCase.forInteractiveUse;\n\nimport matlab.mock.actions.AssignOutputs;\nimport matlab.mock.constraints.WasCalled;\nimport matlab.mock.actions.ThrowException;\n\n%%\n% Mock the <https:\/\/www.mathworks.com\/help\/database\/ug\/database.html\n% database> and the <https:\/\/www.mathworks.com\/help\/database\/ug\/cursor.html\n% cursor>.\n\n% Mock the database and the cursor\n[dbmock, dbbehavior] = createMock(testCase, 'AddedMethods', ...\n    {'isa', 'isopen', 'insert', 'update', 'exec'});\n[cursmock, cursbehavior] = createMock(testCase, 'AddedMethods', ...\n    {'close', 'fetch'}, 'AddedProperties',{'Data'});\n\n%%\n% Define the behavior of cursor and database connection.  Note that these\n% read like English sentences.\n\n% Pass the validation tests\nwhen(withAnyInputs(dbbehavior.isa), AssignOutputs('database.jdbc.connection'));\nwhen(withAnyInputs(dbbehavior.isopen), AssignOutputs(true));\n\n% Return cursor mock when database or cursor are executed\/fetched.\nwhen(withAnyInputs(dbbehavior.exec), AssignOutputs(cursmock));\nwhen(withAnyInputs(cursbehavior.fetch), AssignOutputs(cursmock));\n\n%% \n% We need to build data that looks like what is required.\n\n% Synthetic output times that mimic expectation of multiple hits to a\n% database.\nnowish = datetime('now', 'TimeZone', 'America\/New_York');\nt1 = table([nowish; nowish],  {'Weather'; 'Energy'}, 'VariableNames', {'lastModified', 'tableType'})\nt2 = t1; \nt2.lastModified(1) = t2.lastModified(1)+seconds(1); % Just Weather\nt3 = t2;\nt3.lastModified(2) = t3.lastModified(2)+seconds(3); % Just Energy\n\n% Build table to insert in the format MySQL requires\nc = {'01-May-2007 00:00:00',4854.40000000000,58,30;'01-May-2007 00:05:00',4802.30000000000,58.0833333333333,29.8333333333333;'01-May-2007 00:10:00',4740.30000000000,58.1666666666667,29.6666666666667;'01-May-2007 00:15:00',4700.34155844156,58.2500000000000,29.5000000000000;'01-May-2007 00:20:00',4681.77969924812,58.3333333333333,29.3333333333333;'01-May-2007 00:25:00',4648.99421487603,58.4166666666667,29.1666666666667;'01-May-2007 00:30:00',4633.70864197531,58.5000000000000,29};\ndata = cell2table(c, 'VariableNames', {'Time', 'N_Y_C_', 'TemperatureF_KLGA', 'Dewpoint_KLGA'});\ndata.Time = datetime(data.Time);\ndata.KLGA = [data.TemperatureF_KLGA data.Dewpoint_KLGA];\ndata.TemperatureF_KLGA = [];\ndata.Dewpoint_KLGA = [];\ndata = table2timetable(data)\n\n%%\n% Set up outputs for the Data property.  Error after three uses.\nwhen(get(cursbehavior.Data), ...\n    then(repeat(1, AssignOutputs(t1)), ...\n    then(repeat(1, AssignOutputs(t2)), ...\n    then(repeat(1, AssignOutputs(t3)), ThrowException))));\n\n%%\n% Exercise the system.\n\n% Build DatabaseHandler\ndb = DatabaseHandler(dbmock);\n\n% Add energy and weather (both database tables)\naddData(db, data);\n\n%%\n% Qualify database called properly and that _LastUpdateTime_ property updates\n% correctly.  Add a 1 second buffer for processing time.\ntestCase.verifyThat(withAnyInputs(dbbehavior.insert()), WasCalled('WithCount', 2));\ntestCase.verifyThat(withAnyInputs(dbbehavior.update()), WasCalled('WithCount', 2));\nfirstlut = db.LastUpdateTime;\nnowish = datetime('now', 'TimeZone', 'America\/New_York')+seconds(1);\ntestCase.verifyLessThan(table2array(firstlut), nowish); \n\n%%\n\n% Add just weather (just weather table in database)\naddData(db, data(:, {'KLGA'}));\ntestCase.verifyThat(withAnyInputs(dbbehavior.insert()), WasCalled('WithCount', 3));\ntestCase.verifyThat(withAnyInputs(dbbehavior.update()), WasCalled('WithCount', 3));\nsecondlut = db.LastUpdateTime;\ntestCase.verifyEqual(secondlut.Energy, firstlut.Energy);\ntestCase.verifyGreaterThan(secondlut.Weather, firstlut.Weather);\n\n%%\n\n% Add just energy (just energy table in database)\naddData(db, data(:, {'N_Y_C_'}));\ntestCase.verifyThat(withAnyInputs(dbbehavior.insert()), WasCalled('WithCount', 4));\ntestCase.verifyThat(withAnyInputs(dbbehavior.update()), WasCalled('WithCount', 4));\nthirdlut = db.LastUpdateTime;\ntestCase.verifyEqual(secondlut.Weather, thirdlut.Weather);\ntestCase.verifyGreaterThan(thirdlut.Energy, secondlut.Energy);\n\n%%\n% Going forward, I'd recommend using the MATLAB testing frameworks for your\n% testing needs.  They're an area of MATLAB that has really matured quite\n% well over the last few years.  If you need to design for older releases,\n% then Paul's |MockObject| can certainly help.\n\n%%\n% For another blog post on the MATLAB Mocking Framework, see this\n% <https:\/\/blogs.mathworks.com\/developer\/2017\/07\/06\/dont-mock-me\/ blog\n% post> on the Developer Blog.\n\n%% Comments\n% \n% Give both mocking frameworks a try and let us know what you think\n% <https:\/\/blogs.mathworks.com\/pick\/?p=8880#respond here> or leave a\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/42959-mockobject#comments\n% comment> for Paul.\n%\n \n\n##### SOURCE END ##### 84b0e2ad3c494c7abd40c840c4b7d136\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/pick\/files\/mockdatabase.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>Sean&#8216;s pick this week is Mock Object by Paul Sexton.<\/p>\n<p>Paul has provided a mock object that is useful for mocking inaccessible or slow software or hardware while executing unit<br \/>\n  &#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/10\/06\/mockobject\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"featured_media":8883,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8880"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8880"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8880\/revisions"}],"predecessor-version":[{"id":8884,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8880\/revisions\/8884"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media\/8883"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}