Is there a good way to use a conditional attribute in a testing context?
My thoughts were that if you can do this:
[Conditional("Debug")] public void DebugMethod() { //... }
Perhaps you could use for: (?)
[Conditional("Test")] public void TestableMethod() { //... }
I do not see the point when there is a better alternative: test projects.
Use NUnit or MSTest to achieve this feature in a more elegant way.
I would accept Mehrdad's answer - I just wanted to give more context when you can use these attributes:
, [Conditional], , / ; , , , , ( #if... .. ).
[Conditional]
, . , , , #if, , .
#if
, . , ( , ), .
Let the test code be the test code, and the production code the production code, and let the production code have no idea about it.
Another problem is that you might want to run your unit tests in your release builds. (We certainly do).
Source: https://habr.com/ru/post/1710234/More articles:Handling Unstructured Exceptions in VB.NET 2005/2008 - vb.netWhat type of index is best for type DATE in Oracle? - oracleWhat does hash / pound (#) mean in the format string? - stringCan I group application keys? - groupingOpenGL: The fastest way to draw a mixture of triangles and ATVs? - performanceHow to do application level exception handling in an iPhone application - exception-handlinghttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1710236/symbian-is-it-possible-to-get-access-to-a-list-of-contacts-through-an-application&usg=ALkJrhh54IJLtHSlmk1KvoCiyOaoM8IAawClose or cancel the MFC dialog after a certain period of time - c ++Find the lowest unused number - c ++How can I load FastAGI balance? - load-balancingAll Articles