面向服务开发的基于契约的模拟

F. Solms, L. Marshall
{"title":"面向服务开发的基于契约的模拟","authors":"F. Solms, L. Marshall","doi":"10.1145/2987491.2987534","DOIUrl":null,"url":null,"abstract":"Unit testing of software components requires that a component is tested in isolation. However, many components require the services of other components to provide their functionality. In order to decouple the component being tested from its dependencies, one commonly uses mock objects. Mocking frameworks which are currently used in industry use dynamic mock object generation with the mocking behaviour specified where the mocking is required, e.g. within unit tests. There is no guarantee that the mocking behaviour is consistent with the behaviour required from the component being mocked. Furthermore, these mock objects are not reused across unit tests and other areas where mocking is required.\n We consider an alternative approach to mocking where the mock object is specified against the contract being mocked and reused across unit tests and other code where mocking is required. These mock objects are tested against the component contracts for the components they are mocking. Furthermore, using dependency injection one is able to reuse the functional tests across unit tests (injecting mock objects for the dependencies) and integration tests (injecting actual components for the dependencies). Even though this approach does require more code to be developed for specifying mocking behaviour, this is offset by the mock object being reused across unit tests for components with the same dependency as well as across integration tests.","PeriodicalId":269578,"journal":{"name":"Research Conference of the South African Institute of Computer Scientists and Information Technologists","volume":"1 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2016-09-26","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"2","resultStr":"{\"title\":\"Contract-Based Mocking for Services-Oriented Development\",\"authors\":\"F. Solms, L. Marshall\",\"doi\":\"10.1145/2987491.2987534\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Unit testing of software components requires that a component is tested in isolation. However, many components require the services of other components to provide their functionality. In order to decouple the component being tested from its dependencies, one commonly uses mock objects. Mocking frameworks which are currently used in industry use dynamic mock object generation with the mocking behaviour specified where the mocking is required, e.g. within unit tests. There is no guarantee that the mocking behaviour is consistent with the behaviour required from the component being mocked. Furthermore, these mock objects are not reused across unit tests and other areas where mocking is required.\\n We consider an alternative approach to mocking where the mock object is specified against the contract being mocked and reused across unit tests and other code where mocking is required. These mock objects are tested against the component contracts for the components they are mocking. Furthermore, using dependency injection one is able to reuse the functional tests across unit tests (injecting mock objects for the dependencies) and integration tests (injecting actual components for the dependencies). Even though this approach does require more code to be developed for specifying mocking behaviour, this is offset by the mock object being reused across unit tests for components with the same dependency as well as across integration tests.\",\"PeriodicalId\":269578,\"journal\":{\"name\":\"Research Conference of the South African Institute of Computer Scientists and Information Technologists\",\"volume\":\"1 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2016-09-26\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"2\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Research Conference of the South African Institute of Computer Scientists and Information Technologists\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.1145/2987491.2987534\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Research Conference of the South African Institute of Computer Scientists and Information Technologists","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/2987491.2987534","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 2

摘要

软件组件的单元测试要求对组件进行隔离测试。然而,许多组件需要其他组件的服务来提供它们的功能。为了将被测试的组件与其依赖关系解耦,通常使用模拟对象。目前在工业中使用的模拟框架使用动态模拟对象生成,并在需要模拟的地方指定模拟行为,例如在单元测试中。不能保证模拟行为与被模拟的组件所需的行为一致。此外,这些模拟对象不能跨单元测试和其他需要模拟的领域重用。我们考虑了另一种模拟方法,即根据被模拟的契约指定模拟对象,并在单元测试和其他需要模拟的代码中重用。这些模拟对象是针对它们所模拟的组件的组件契约进行测试的。此外,使用依赖项注入可以跨单元测试(为依赖项注入模拟对象)和集成测试(为依赖项注入实际组件)重用功能测试。尽管这种方法确实需要开发更多的代码来指定模拟行为,但这可以通过在具有相同依赖关系的组件的单元测试中重用模拟对象以及跨集成测试来抵消。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
Contract-Based Mocking for Services-Oriented Development
Unit testing of software components requires that a component is tested in isolation. However, many components require the services of other components to provide their functionality. In order to decouple the component being tested from its dependencies, one commonly uses mock objects. Mocking frameworks which are currently used in industry use dynamic mock object generation with the mocking behaviour specified where the mocking is required, e.g. within unit tests. There is no guarantee that the mocking behaviour is consistent with the behaviour required from the component being mocked. Furthermore, these mock objects are not reused across unit tests and other areas where mocking is required. We consider an alternative approach to mocking where the mock object is specified against the contract being mocked and reused across unit tests and other code where mocking is required. These mock objects are tested against the component contracts for the components they are mocking. Furthermore, using dependency injection one is able to reuse the functional tests across unit tests (injecting mock objects for the dependencies) and integration tests (injecting actual components for the dependencies). Even though this approach does require more code to be developed for specifying mocking behaviour, this is offset by the mock object being reused across unit tests for components with the same dependency as well as across integration tests.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信