How to unit test non-exported class in UWP component (C++/WinRT)









up vote
0
down vote

favorite












I'm looking for some guidance on my strategy for unit testing UWP components.



I am developing a UWP component using the C++/WinRT projection. This component contains a helper class that manages communication with a Bluetooth device. I would like to write unit tests for that helper class (BthDevice) without exporting them to the UWP component's interface.



I started by following some guidelines for testing non-exported DLL classes. Specifically, I created a new UWP unit test project. I explicitly added my project's include directory, included BthDevice.h, and added the class' BthDevice.obj to the linker settings. I fought a few linker errors, and now it's falling over because I'm using precompiled headers in the UWP component. I've given up for now.



It feels like this should be a simple task, and that I'm going about it the wrong way. Any guidance is welcome! Thanks.










share|improve this question







New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • You can immediately access an implementation type, as long as the API is implemented in the consuming project.
    – IInspectable
    2 days ago











  • In my case, I'm trying to unit test an implementation type from a UWP Unit Test project. So, the implementation type is NOT implemented in the consuming project.
    – Sean Kelly
    yesterday










  • If you #include the implementation file into a compilation unit of your test project, then that implementation type is implemented in the consuming project. At least that appears to be a workable solution, although I never used the built-in testing framework.
    – IInspectable
    yesterday














up vote
0
down vote

favorite












I'm looking for some guidance on my strategy for unit testing UWP components.



I am developing a UWP component using the C++/WinRT projection. This component contains a helper class that manages communication with a Bluetooth device. I would like to write unit tests for that helper class (BthDevice) without exporting them to the UWP component's interface.



I started by following some guidelines for testing non-exported DLL classes. Specifically, I created a new UWP unit test project. I explicitly added my project's include directory, included BthDevice.h, and added the class' BthDevice.obj to the linker settings. I fought a few linker errors, and now it's falling over because I'm using precompiled headers in the UWP component. I've given up for now.



It feels like this should be a simple task, and that I'm going about it the wrong way. Any guidance is welcome! Thanks.










share|improve this question







New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • You can immediately access an implementation type, as long as the API is implemented in the consuming project.
    – IInspectable
    2 days ago











  • In my case, I'm trying to unit test an implementation type from a UWP Unit Test project. So, the implementation type is NOT implemented in the consuming project.
    – Sean Kelly
    yesterday










  • If you #include the implementation file into a compilation unit of your test project, then that implementation type is implemented in the consuming project. At least that appears to be a workable solution, although I never used the built-in testing framework.
    – IInspectable
    yesterday












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm looking for some guidance on my strategy for unit testing UWP components.



I am developing a UWP component using the C++/WinRT projection. This component contains a helper class that manages communication with a Bluetooth device. I would like to write unit tests for that helper class (BthDevice) without exporting them to the UWP component's interface.



I started by following some guidelines for testing non-exported DLL classes. Specifically, I created a new UWP unit test project. I explicitly added my project's include directory, included BthDevice.h, and added the class' BthDevice.obj to the linker settings. I fought a few linker errors, and now it's falling over because I'm using precompiled headers in the UWP component. I've given up for now.



It feels like this should be a simple task, and that I'm going about it the wrong way. Any guidance is welcome! Thanks.










share|improve this question







New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm looking for some guidance on my strategy for unit testing UWP components.



I am developing a UWP component using the C++/WinRT projection. This component contains a helper class that manages communication with a Bluetooth device. I would like to write unit tests for that helper class (BthDevice) without exporting them to the UWP component's interface.



I started by following some guidelines for testing non-exported DLL classes. Specifically, I created a new UWP unit test project. I explicitly added my project's include directory, included BthDevice.h, and added the class' BthDevice.obj to the linker settings. I fought a few linker errors, and now it's falling over because I'm using precompiled headers in the UWP component. I've given up for now.



It feels like this should be a simple task, and that I'm going about it the wrong way. Any guidance is welcome! Thanks.







visual-c++ uwp c++-winrt






share|improve this question







New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Sean Kelly

22




22




New contributor




Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Sean Kelly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • You can immediately access an implementation type, as long as the API is implemented in the consuming project.
    – IInspectable
    2 days ago











  • In my case, I'm trying to unit test an implementation type from a UWP Unit Test project. So, the implementation type is NOT implemented in the consuming project.
    – Sean Kelly
    yesterday










  • If you #include the implementation file into a compilation unit of your test project, then that implementation type is implemented in the consuming project. At least that appears to be a workable solution, although I never used the built-in testing framework.
    – IInspectable
    yesterday
















  • You can immediately access an implementation type, as long as the API is implemented in the consuming project.
    – IInspectable
    2 days ago











  • In my case, I'm trying to unit test an implementation type from a UWP Unit Test project. So, the implementation type is NOT implemented in the consuming project.
    – Sean Kelly
    yesterday










  • If you #include the implementation file into a compilation unit of your test project, then that implementation type is implemented in the consuming project. At least that appears to be a workable solution, although I never used the built-in testing framework.
    – IInspectable
    yesterday















You can immediately access an implementation type, as long as the API is implemented in the consuming project.
– IInspectable
2 days ago





You can immediately access an implementation type, as long as the API is implemented in the consuming project.
– IInspectable
2 days ago













In my case, I'm trying to unit test an implementation type from a UWP Unit Test project. So, the implementation type is NOT implemented in the consuming project.
– Sean Kelly
yesterday




In my case, I'm trying to unit test an implementation type from a UWP Unit Test project. So, the implementation type is NOT implemented in the consuming project.
– Sean Kelly
yesterday












If you #include the implementation file into a compilation unit of your test project, then that implementation type is implemented in the consuming project. At least that appears to be a workable solution, although I never used the built-in testing framework.
– IInspectable
yesterday




If you #include the implementation file into a compilation unit of your test project, then that implementation type is implemented in the consuming project. At least that appears to be a workable solution, although I never used the built-in testing framework.
– IInspectable
yesterday

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Sean Kelly is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225095%2fhow-to-unit-test-non-exported-class-in-uwp-component-c-winrt%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Sean Kelly is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















Sean Kelly is a new contributor. Be nice, and check out our Code of Conduct.












Sean Kelly is a new contributor. Be nice, and check out our Code of Conduct.











Sean Kelly is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225095%2fhow-to-unit-test-non-exported-class-in-uwp-component-c-winrt%23new-answer', 'question_page');

);

Post as a guest














































































Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo