Mm, okay, so I finally got around to adding unit tests to my project. I was right about ReSharper; it rocks. The license is good, too. They call it a "named license", where the person named can be running one instance at a time, anywhere. So, you can install it on several machines, and as long as you are only using one of them at a time, you are adhering to the license.
I like it.
I had to make some decisions regarding the unit testing. Spring.NET has some built-in NUnit thing, but I chose to go with the latest and greatest, so I'd know what I was getting. I don't like to look for old docs.
As usual, adding test meant re-working a bunch of the code to accommodate it. The code is better for it, of course, and I am once again reminded why you add tests from the beginning. I won't learn, though.
There were special considerations where Spring.NET is concerned. Should I use it to wire everything together for the tests, too? It would be appropriate, at least at an integration level. Did that make sense at the unit level?
I decided, after some experimentation, that no, that "manually" wiring things together in the test suites was the way to go, with some separate tests including Spring.NET to be sure that part is working okay.
The configuration flexibility that IoC brings is inappropriate for testing, I think, because the tests should always reflect what needs to be tested, in isolation. External factors, such as what is in a config file, shouldn't be part of the tests.
Many of the changes I had to make in response to this decision dealt with writing getters and setters for private variables. Spring.net may be able to set private variables, but I'm not going to jump through the hoops to do it from a test. Once I was forced to make a decision, going with "anything that can be configured should be configurable to whatever creates it" strategy, and adding some extra checks so things don't get broken seems best, at least for now.
I'm sure I'll get pissed off about it at some point.
Friday, April 24, 2009
Versioning, and Versioning on Windows
I'm currently using git for my versioning needs, specifically msysgit on Vista. I got spoiled on distributed version control systems when I was running Ubuntu on my desktop. Bazaar was my choice then, especially since it ran just fine on Windows, too.
I've moved onto git since then, mostly because it looks like it has the most momentum. Now that I've made the switch, I'm happy. It is nice to finally have a tool which fits whatever workflow you want to throw at it, instead of having to adjust your workflow for it.
I've been a proponent of VCS as an IT goon for a long time. They aren't just useful for versioning code, they are useful for versioning all kinds of files. Some of the easiest deployment environments I've worked in and built had their production content under version control. Rollbacks were trivial, the "what changed" question was easily answered, revision numbers were part of change management.
Making a copy of everything isn't versioning, it is only rollback. Copies are just backup. It is good enough, but it isn't particularly smart.
Distributed version control is even cooler than the old fashioned (like, a couple of years ago!) centralized VCS. The previous generation required a centralized server, even if it was one user on the same machine. DVCS lets you start versioning on-the-fly.
Having things versioned makes it easy to fix your mistakes, giving you the freedom to experiment. When you screw up, you just go back to where you started. Or you can see exactly what you changed that might've screwed things up, so you can fix it faster. Are you building up a text document describing whatever it is you're working on, even just as notes? Version it. Seriously.
Of course, on Windows this all sucks. There is a GUI for git, and it is adequate, but it doesn't really unleash the Power of Git. The tools are good enough that there isn't really a reason for not using them, though.
Microsoft's versioning story is very weak. Team Foundation Server ain't gonna cut it. We need it a little bit more integrated. And free. I mean, really, when people are happily giving away the next-gen technology, you can count that part of the product as "obsolete". I'm not holding out for something at the file system level. Yet. (nor network aware, yet, either - but if they want to be better, they've got to get ahead of this)
So, in the meantime, I have a couple of Powershell aliases to help me out. I want to spend more time writing better ones, but to really get into it, I'd need to write it as a cmdlet, and I don't have the time. And I shouldn't have to - something like this should be shipped in the OS. It should be pretty, it should be easy, it should be powerful, and it should be programmable. That's just to catch up.
Here's what I'm using in $profile (I've got gvim installed for my editor. Suck it, notepad):
I know, not much to go with. More complex aliases are prohibitive, and functions look like functions, parenthesis and all. As I get a better understanding of how best to use git, I'm coming up with what it will take to simplify my own specific workflow. I'll share them as I do them.
I've moved onto git since then, mostly because it looks like it has the most momentum. Now that I've made the switch, I'm happy. It is nice to finally have a tool which fits whatever workflow you want to throw at it, instead of having to adjust your workflow for it.
I've been a proponent of VCS as an IT goon for a long time. They aren't just useful for versioning code, they are useful for versioning all kinds of files. Some of the easiest deployment environments I've worked in and built had their production content under version control. Rollbacks were trivial, the "what changed" question was easily answered, revision numbers were part of change management.
Making a copy of everything isn't versioning, it is only rollback. Copies are just backup. It is good enough, but it isn't particularly smart.
Distributed version control is even cooler than the old fashioned (like, a couple of years ago!) centralized VCS. The previous generation required a centralized server, even if it was one user on the same machine. DVCS lets you start versioning on-the-fly.
Having things versioned makes it easy to fix your mistakes, giving you the freedom to experiment. When you screw up, you just go back to where you started. Or you can see exactly what you changed that might've screwed things up, so you can fix it faster. Are you building up a text document describing whatever it is you're working on, even just as notes? Version it. Seriously.
Of course, on Windows this all sucks. There is a GUI for git, and it is adequate, but it doesn't really unleash the Power of Git. The tools are good enough that there isn't really a reason for not using them, though.
Microsoft's versioning story is very weak. Team Foundation Server ain't gonna cut it. We need it a little bit more integrated. And free. I mean, really, when people are happily giving away the next-gen technology, you can count that part of the product as "obsolete". I'm not holding out for something at the file system level. Yet. (nor network aware, yet, either - but if they want to be better, they've got to get ahead of this)
So, in the meantime, I have a couple of Powershell aliases to help me out. I want to spend more time writing better ones, but to really get into it, I'd need to write it as a cmdlet, and I don't have the time. And I shouldn't have to - something like this should be shipped in the OS. It should be pretty, it should be easy, it should be powerful, and it should be programmable. That's just to catch up.
Here's what I'm using in $profile (I've got gvim installed for my editor. Suck it, notepad):
$vimexe = $env:USERPROFILE + '\sys\vim72\gvim.exe'
new-alias -name vi -value $vimexe
$gitexe = $env:USERPROFILE + '\sys\git\bin\git.exe'
new-alias -Name git -Value $gitexe
# git wants a HOME
$env:HOME = $env:USERPROFILE
$env:EDITOR=$vimexe
I know, not much to go with. More complex aliases are prohibitive, and functions look like functions, parenthesis and all. As I get a better understanding of how best to use git, I'm coming up with what it will take to simplify my own specific workflow. I'll share them as I do them.
Labels:
babble,
git,
powershell
Monday, April 20, 2009
MS or OSS? Integration v. Features
I have to make a decision about a testing framework for my little project. I can't put it off any longer, or I'll really regret it.
At least in this category there's no shortage of options.
The power of a well-integrated solution shouldn't be dismissed. There's real merit in being able to get things going with a minimum of fuss, at the cost of long-term flexibility.
In this case, it doesn't look like I'll have to worry about it. ReSharper apparently integrates NUnit nicely.
At least in this category there's no shortage of options.
- NUnit. Part of the xUnit family. Among them, they have very similar syntax and capabilities.
- MSTest. This has a similar syntax, and is really well integrated into Visual Studio
The power of a well-integrated solution shouldn't be dismissed. There's real merit in being able to get things going with a minimum of fuss, at the cost of long-term flexibility.
In this case, it doesn't look like I'll have to worry about it. ReSharper apparently integrates NUnit nicely.
log4net and Spring.Net, once again
Here's the goo to configure log4net in your spring.net config, assuming a property of type ILog named "log". It will initialize it with a named logger for "Document".
Not that much to it, after all.
<property name="log">
<object type="log4net.LogManager,log4net" method="GetLogger">
<constructor-arg value="Document">
</constructor-arg></object>
</property>
Not that much to it, after all.
Labels:
dev,
log4net,
spring.net
Logging Should Be Added Early
The problem with starting a project just to see what happens is that you always forget the important things, because they "slow things down".
Like logging. When I was just poking around with a couple of components, wiring them together crudely, it didn't matter. If I wanted to see what the program was doing, I'd just break in with the debugger. Nothing to it.
Of course, now that I'm actually trying to get things to work well, logging is suddenly important. The only thing that is saving my ass is that I'm rewriting large chunks to better suit my scenario, so I can add logging at that point.
The only thing dumber than putting off logging is putting off a test suite!
Aw, hell...
Like logging. When I was just poking around with a couple of components, wiring them together crudely, it didn't matter. If I wanted to see what the program was doing, I'd just break in with the debugger. Nothing to it.
Of course, now that I'm actually trying to get things to work well, logging is suddenly important. The only thing that is saving my ass is that I'm rewriting large chunks to better suit my scenario, so I can add logging at that point.
The only thing dumber than putting off logging is putting off a test suite!
Aw, hell...
Subscribe to:
Posts (Atom)