Created
October 26, 2014 17:12
-
-
Save andyhasit/a07cf3f473209343bdfd to your computer and use it in GitHub Desktop.
MircoTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace DataTransferScript # ThirtyLineTestFramework | |
import System | |
import System.Reflection | |
import System.Runtime.Serialization | |
def RunTests(): | |
passCount = 0 | |
failCount = 0 | |
previousConsoleColour = Console.ForegroundColor | |
print "Running Tests" | |
myAssembly = Assembly.GetExecutingAssembly() | |
for type in myAssembly.GetTypes(): | |
for methodInfo in type.GetMethods(): | |
if methodInfo.Name.StartsWith("Test"): | |
try: | |
myObject = FormatterServices.GetUninitializedObject(type) | |
methodInfo.Invoke(myObject, null) | |
Console.ForegroundColor = ConsoleColor.Green | |
print "${methodInfo.Name}" | |
passCount += 1 | |
except e as Exception: | |
Console.ForegroundColor = ConsoleColor.Red | |
print "${methodInfo.Name}" | |
print e | |
failCount += 1 | |
Console.ForegroundColor = previousConsoleColour | |
print "Found ${passCount + failCount} tests. Pass: ${passCount}. Fail: ${failCount}." | |
Console.ReadLine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment