Porting my projects to C#

Back in Ye Olden Times when I went to college, object-oriented programming was barely starting to become a thing. It didn’t help matters that the particular school I went to was behind the times on its computer science program, either. So I didn’t discover until I was actually in the workforce that of all the languages I’d learned about in college, the only one that was at all useful was C.

C# hadn’t been invented yet when I graduated. When I look it up, I see that Microsoft put out the first release of C# around 2000 (source: Wikipedia’s C# page), and by then, I was working at Attachmate. Attachmate was one of the last times I had any opportunity to work with C++, aside from one short contract I had after they laid me off.

Up till then, my only work at Microsoft (my full-time stint there in the early 90’s, and my contract work in the mid-90’s), was pre-C#. My next work at Microsoft, the two back-to-back contracts I had from 2003 to 2005, was straight up testing: a mix of manual testing and running automation written by the team’s actual employees. I didn’t have any opportunity to work with any language directly myself, much less C#.

After that, all of the full time gigs I’ve had were ones functioning outside the Microsoft-based ecosystem. Big Fish in particular was a Python and Java environment. Which has been great for my accrual of Java and Python experience!

But now that I’m back on the job market, I’m seeing regular signs of jobs asking for C# coming across my radar. So far, I’ve had to tell recruiters that I don’t have any professional experience working with the language, or for that matter with modern versions of Visual Studio. (The last time I would have seen any version of Visual Studio would have been that aforementioned short contract. According to my old resumes, round about then, I was mentioning working with Visual Studio 6.0 and Visual Studio .NET.)

I figured, though, that as long as I have time on my hands it would behoove me to try to actually get some hands-on experience with the current release of Visual Studio and with C#. And, since I’ve been told by former Big Fish colleagues that C# is very, very similar to Java overall, I figured I’d try to port my current Java work up on Github over into C#.

As of this writing, I have done this! The code I’ve ported so far is the little test suite that runs the REST API tests against my test WordPress site. This ported code now lives on my Github in its own repo.

Things I have learned from this experience

I do not like Visual Studio as much as I do IntelliJ for an IDE. But since part of this entire point was to practice getting hands-on experience with a current Visual Studio version, I put up with that. And it helped that I figured out a few ways to make Visual Studio less cluttered, by docking the things I need access to off on the side to be hidden until I need them. That frees up most of the screen on my dev laptop for me to see my code.

C# is, indeed, a LOT like Java. It’s simultaneously enough like Java and enough different from Java that the little differences will probably catch me up a lot if I wind up regularly working with this language. Nothing I couldn’t eventually get used to. But it’ll be a thing I’ll need to look out for.

I don’t like that Visual Studio makes me have to re-add a file in git every time I change it. (IntelliJ does not make me do this, even on Windows.) When I went googling about this, I found that this is apparently by design.

I do like the concept of a “namespace” that’s apparently a thing in C#. If I understand it correctly, the idea here is to have a big set of associated files. This seems to simplify matters a bit, and has saved me having to do a few extra import statements.

Oh wait, I’m sorry, not “import”. “Using”. See previous commentary re: differences between C# and Java.

Something else I’m still having to get used to, and this is a question of “quirks of the IDE” as opposed to “quirks of the language”: if I want to run tests in Visual Studio, I have to hit the Test Explorer for that. I can’t build the project directly, otherwise it’ll complain at me. This seems to be because I’ve built my various test classes as class libraries, as per various tutorials I’ve seen on how to set up tests. Which means in turn that Visual Studio won’t let me run them directly. Apparently you only get to run things in Visual Studio if you’re specifically building executables?

Lastly, a quibble of terminology: I don’t like that Visual Studio calls its projects “solutions”. It’s a bit too rah-rah YAY GO SOLVE YOUR PROBLEM for me. And I’m all “yes yes I’m going to STOP TRYING TOO HARD TO HELP ME”, here.

Which, I feel, exemplifies my experience with Microsoft products overall rather well.

Specific libraries I’ve discovered

A lot of this porting work has been “learn how to deal with the language” as well as “learn how to deal with the IDE”. But there’s also been some measure of “find C# equivalents of the technology I’m used to dealing with in Java”. One of these has been TestNG. The recommended C# version of this is apparently NUnit, which seems fine so far. Learning how to deal with this has been just a question of learning its specific syntax for annotating test methods.

Likewise, the current recommended way of doing REST API testing in C# seems to be RestSharp. From what I saw in my googling, apparently there’s now an in-language way of doing this, but I stuck with RestSharp as it seemed a good analog of the Unirest library I learned how to use on the Java side.

Lastly, since I needed to find an equivalent for how Java parses JSON, I went with LINQ to JSON in the JSON.NET/Newtonsoft library. This has been a pretty close match to the json.org libraries you can use in Java, and gives me the same level of ability to parse JSON payloads without having to worry about deserializing them.

(Which took me a bit of work to discover. RestSharp’s docs seemed to really really REALLY want me to deserialize JSON I get back on REST API calls. This is not helpful if all I really want to do is look into the JSON and go “yes, I see the correct value(s) in there”, as opposed to actually saving the stuff out into variables and doing additional things with it.)

What’s next

I also want to port the Selenium-based tests into C#. But since the Java version of these tests specifically uses Selenide as a framework to do its testing, I want to find a C# library that does the same thing. Atata seems promising and I shall investigate it.

Tutorials I’ve found so far for how to do Selenium-based testing in C# talk a lot about how to install Selenium and browser drivers into your Visual Studio. I don’t actually need to do that, given that I already have a Docker grid running. And since I already know how Selenium works, all I really need to know is how to get my C# code pointed at a Selenium grid.

Job descriptions that come across my radar also keep periodically mentioning Cucumber. This is a thing I discovered during my last research project at Big Fish, so I’ve been a bit interested in checking it out. I don’t know yet how well it plays with C#. This may also require investigation.

All in all

This has been a valuable experience so far. I can now say with assurance that if called upon to do so, I can in fact deal with both C# and Visual Studio.

Under no circumstances can I be called an expert, mind you. And I would still not be a good job match for any position that requires multiple years of experience working in the C# realm. But for any position with a bit more flexibility, where they’d be willing to go “oh sure, you have experience with Java and Python and have at least SEEN C#? We can work with this”? I could do that.

Also: given that I’m an amateur musician, I do have to say, I do like that the language is called C#. I play that note a lot on my fiddle and on my winds. I’ll take any little connection to music in this endeavor that I can get. :D

Coding projects update

As of this writing, I now have a total of five repositories on my Github account: the misc-configs repo for various config/supplementary files, and two each for Java and Python work. For each of those languages, I have a repo for the REST API portion of this project, and one for the Selenium.

All of the repos can be seen on my Github account.

What I’ve been calling the rough “phase 1” of this project is now more or less complete. I’ve got basic test cases in place in both languages for both the REST API side, and the Selenium side. As I’ve written about before, the API tests are dealing with the service endpoints that handle publicly viewable information. The Selenium tests are mostly oriented around testing parts of the homepage of my little test WordPress site.

Now I’m moving into the rough “phase 2”. In this phase, I’m adding more Selenium tests. This’ll include adding some sidebar tests for the homepage, as well as tests for additional sections of the site (a post and a page), and making sure that the elements are correct on the selected links. I’ll also be testing site search and adding a new comment to a previously existing post, since that’s something I can do without authentication.

“Phase 3” of this project will get into dealing with stuff that requires authentication. From the REST API side, this’ll mean dealing with the service endpoints that handle things at the site admin level (such as making a new post or comment, or editing a previously existing one). From the Selenium side, I’ll want to see about verifying logging in and logging out of the site, and making sure that the links displayed in the “META” area of the sidebar update themselves accordingly.

(NOTE: I am NOT going to try to test the actual WordPress admin UI. That’s a whole different kettle of fish than testing a front-facing site.)

In related news, I’ve also discovered the Githubs “Projects” functionality, and I’ve made myself a project there to cover the work I’m doing. This amuses me, as their Projects board looks a lot like JIRA, the bug tracking/project management software we used at my Former Day Job, as well as at the short contract I had after the layoff at the tail end of last year.

Interested parties can find my current active project on my Github projects page. I’ll be adding additional projects to that once this one is complete–like the WordPress plugin work I want to do!

I’ve actually had job recruiters and interviewers ask me about this work, now that I’ve got a link to my Github on my resume. This has proven beneficial in interviews I had last week, and I even got useful tips on additional libraries I can research, as well as aspects of version 8 of Java I hadn’t had experience with yet. I’ve gotten positive feedback about how I do comments on things, as well as on the various Readmes I’ve put on the repos.

So while the work hasn’t yet actually proven critical in landing me a job, it has proven useful in helping me demonstrate that I not only know how to code, but that I like it well enough to do it on my own time and to plan out larger projects.

This is, I feel, a very valuable thing for me to be able to demonstrate.

Coding projects update

I now have three active repositories up on my Github account. These are:

misc-configs: This one is for miscellaneous config files that are useful for the tests in the other repositories. What’s in here will mostly make sense to you if you are familiar with a) how to import data into a WordPress site, b) how to import Collections or Environment files into Postman, and/or c) how to use a YAML file to run Docker Compose to launch one or more containers.

wp-test-demo-java: This one is for my demo of testing the REST API endpoints made available by WordPress for any given site. Phase 1 of the work on this demo is complete, in which I test against the endpoints that handle publicly accessible data. I.e., the kinds of things you could find out about a WordPress site if you’re just a visitor to the site.

wp-test-demo-java-selenium: This demo is also using my test WordPress site, but here, I am doing front end testing rather than service testing. I’m using the Selenide Java library to run tests against the site via Selenium, a widely used automation framework for testing web pages. Selenide is a layer on top of Selenium that does the heavy lifting of Selenium setup for me, and frees me up to focus on the test cases I want to run.

This is a work in progress, but as of this post it has 27 test cases in it. There are more to come.

Other projects that’ll be showing up on my Github account include:

  • Phase 2 of the REST API project, which would involve hitting service endpoints that specifically require authentication.
  • Porting the Selenium tests over into Python, and structuring them in such a way as to be similar to the Python test framework we used on my former team at Big Fish. The intent here would be to demonstrate my ability to use Selenium in Python, and to write up a framework for it. (Which will require more work than the equivalent testing in Java!)
  • The teeny WordPress plugin I want to do that’ll make nice Dreamwidth-style user and community name tags in a post or page for me. (This is the one I’ve mentioned before that would be an expansion on the very old plugin that does this for LJ user and community tags.) This would be written in PHP, and the intent HERE would be to show my comfort level with PHP. I haven’t used this language as much in a professional context, but I HAVE used it a lot over the years dealing with my websites, and I can demonstrate that here.

Stretch goals:

  • Do something in JavaScript. What, I don’t know yet, but the obvious possibility would be to port some or all of the previously mentioned Selenium tests.
  • Since I do have a locally running plugin on annathepiper.org that fuels my Roleplay Logs page, time permitting, I’d like to do a more solid version of that. Right now the plugin I’m running is a hack of the previous non-Wordpress-based code, and it talks to a database outside the WordPress structure. A cleaner version of this would actually be properly integrated with WordPress. If I get really fancy, I could do an entry form in the Admin UI for WordPress to allow the addition of new logs, and possibly even reading them in via the Media section of the site. This would, of course, also be written in PHP. More on this as events warrant!

Today’s WordPress Test Demo update

Good progress on the coding project today! \0/ Things accomplished:

  • Added new test cases involving Categories, Tags, Pages, and Comments, to bring the total number of test cases up to 10
  • Added the ability to run the cases via a Maven configuration as well as TestNG, and updated my pom.xml to use the testng.xml as its suite file
  • Checked all the new test cases and related work into wp-test-demo-java
  • Renamed my wordpress-dev repo to misc-configs, because that’s really what it’s for miscellaneous config files
  • Updated my Postman collection to include all the endpoints for the test cases I wrote today, and checked the new version of that into misc-configs
  • Updated the Readmes on both wp-test-demo-java and misc-configs to more clearly explain what the repos are for, particularly wp-test-demo-java, as I’ll be pointing recruiters at that
  • Installed Jenkins (again) on my dev laptop, so that I can run the automation as a local Jenkins job as well as within IntelliJ, and to keep up my practice using Jenkins

I have decided, too, that I’ll be doing this project in phases.

Phase 1: REST API tests that hit the endpoints that can serve up publicly available data. I.e., the kinds of data you’d see as a user just browsing a WordPress site.

Phase 2: Selenium-based tests that will do front-end type tests. For example, “If I click on this link, does it take me to this expected target page?” Or, “If I click on this thing on the menu, do I get the correct dropdown off of it?”

Phase 3: This is the ambitious part. There are also REST API endpoints for WordPress that’ll let you get at the stuff you’d ONLY see as an authenticated user, such as post revisions and settings and the like. Time permitting, I may learn about the various ways to actually do that authentication properly so that the test suite can actually get at those endpoints.

Right now, though, I’m going to focus on phases 1 and 2.

The WordPress testing demo project is now underway

Spent most of today (very roughly during ‘work’ hours, just to try to keep to the whole idea of coding to a schedule) working on the WordPress testing demo project I talked about in my last post. As of this writing, I have some actual working things checked in up on Github. There’s only one functional test case so far, but it’s a start!

What I accomplished today:

  • Creating a Github repo for this work
  • Read about the API endpoints that WordPress makes available for any given site, some of which are publicly viewable, others of which require you to log in as a valid user
  • Started a Postman Collection to keep track of the endpoints I’ll be playing with for my test site, and checked an initial version of this in on Github
  • Refreshed my memory about how Unirest works, as this was the library we used at Big Fish to talk to various services; maybe not the most current library to use, but it’s the one I know, so I’m going with this for demo purposes
  • Got IntelliJ on the Linux partition of my dev laptop updated to the latest version
  • Built the actual project in IntelliJ, as a Maven project, so it’d have the correct file structure and a pom.xml file I could add dependencies to
  • Started building a client class that will use Unirest to hit those endpoints for my local test site
  • Built a BaseTest class in charge of doing setup used by all the test classes I’ll be making
  • Built a TestPosts class to start the test cases for the “Posts” endpoints in the aforementioned API, and now it even has an initial functional test case!

Now that I have an actual working (if tiny) framework here, I should be able to fill in some test cases reasonably quickly.

Note also that the test suite assumes I am running the WordPress test site locally. For bonus usefulness I should make some sort of healthcheck test case that verifies that the test site is in fact UP.

Further planning for doing my coding demo project

Since I continue to have time on my hands and no active leads bringing me in for interviews this coming week (so far), I’m moving forward with laying down the plans for my coding demo.

As I said in my last post about this (here for those of you reading on Dreamwidth), I’ve succeeded in setting up a test WordPress site in Docker.

The rest of this operation is going to look something like this, at least for phase 1 of this project:

  • Actually get some content into that test WordPress site. This will probably involve just doing a database copy down from my backup WordPress site up on angelahighland.wordpress.com. If for some reason I can’t do that, I’ll install a lorem ipsum generator plugin (there are a few for WordPress, I looked) and generate purely random content.
  • Study up on the REST API WordPress makes available for any given install.
  • Once I know what service endpoints are available, use that to scope out what test cases I can do.
  • Write out those test cases in a Java BVT suite, similar to the ones I wrote at Big Fish. Tools I will need for this: IntelliJ, TestNG.

A possible Phase 2 for this project will involve extending the testing to include front-end testing. In other words (for those of you unfamiliar with how web testing works), hitting the pages of the test site in a browser and verifying that expected things are there, and/or that you are able to do certain things (e.g., log in, do a search, leave a comment). Tools I will need for this: Selenium (also in a Docker image), with a side helping of the Selenide framework. This would be a followup on my previous research that I did as one of my last projects at Big Fish.

Possible stretch goal: replicate some of the same test cases in Python, just to brush up on my Python skills. Tools I’d be using in this part of the work: PyCharm.

I’ve been writing out some tasks for myself in Things, by way of a task breakdown, and I suppose this blog post kind of counts as a spec. Ha. :D

And when I’ve got some actual code, I’ll be checking it in on my personal Github account. This will be fun, hopefully, as well as a way to keep my skills active until such time as I can convince somebody to give me another job!

(EDITING TO ADD: This, by the way, is a separate project I’m planning in addition to doing a WordPress plugin! So I’ll have multiple things I can eventually point at by way of demonstrating I can code. What I’m talking about in this post is more along the lines of demonstrating something similar to the last code I wrote at Big Fish.)

Practicing with running WordPress in Docker today

So one of the things I want to do during my between-jobs downtime is practice my coding. And in particular, since I thought it’d be nice to a) start small and b) play with something I’m actually interested in coding (as opposed to, say, just focusing on random interview-type questions which will eventually bore me to tears), I decided I’d try to play with making a small WordPress plugin.

I’ve already done one that I’m running locally on Annathepiper.org: namely, to show y’all my archive of roleplay logs. Eventually I want to do a newer version of that, something that might let me actually practice setting up a simple web service.

For now though I’m going to do something less complicated. There’s a very old plugin called “lj-tag-parser”. This thing has a very simple job: allowing the LJ-style syntax for usernames and communities in your WordPress posts and comments. I’m using it right here on annathepiper.org, which is why you can actually see LJ-style usernames and tags if I write something like, say, userinfoannathepiper.

However, this thing hasn’t been updated in ages. And I thought it’d be nice to expand it to allow Dreamwidth-style syntax in addition to LJ-style, and possibly also allow generation of such tags via shortcodes.

But before I do all of that, I wanted to make sure I could set up a clean WordPress dev install.

In the past, when I’ve played around with dev-type WordPress stuff, I just did this on a separate blog on my annathepiper.org network. But coming at this with my SDET hat on, I thought it’d be cleaner and more appropriate to developing my coding experience if I set it up the way I’d do it in a work environment.

Which means a brand new, clean WordPress dev install. And in particular, using official WordPress and MySQL images from Docker.

For those of you who aren’t in the tech industry, suffice to say that Docker is a tool that lets you do exactly this kind of thing. You can set up a thing you want to play with in its own little container on your system, without having to worry about it interfering with anything else you might be doing. Docker lets you go about this in a few different ways. You can go get official images for things (like, say, the latest WordPress install) and do a single run using that image.

Or, if you want to do something a bit more complicated (like, say, running the official WordPress image AND a MySQL image that you’ll need to actually power the WordPress install), you can chain them together using a thing called Docker Compose.

Docker Compose works by you setting up all the config data you need in a file called docker-compose.yml. I’m still fairly new to the syntax this thing requires, but fortunately, I learned a bit about it while I was still at my previous day job at Big Fish. So I was able to utilize that knowledge to build a file that’d let me set up that clean WordPress dev install I want.

I did have to jump through a few hoops to get all the info I needed, though. Here are some pages that proved useful:

So now, as of this writing, I have a nice little set of Docker containers running on my dev box on Linux. And the nice thing about doing this via Docker, especially, is that I could take this exact same docker-compose.yml, reboot my box into Windows, and use it there too. All I need to be running locally is Docker and Docker Compose. The rest of it comes in with the images I specify!

And for the interested, I have checked in my final docker-compose.yml up on my personal Github account, and you can see it right here.

Rough test plan for my first indie SDET project

In order to keep my SDET skills active, and to have something I can point hiring managers at, I’m going to do some test projects that will use this very site as the test bed. Here’s a rough plan for how this is going to work.

Requirements

  • Using Python, write a small Selenium suite that will test dev.annathepiper.org from the front end.
  • Using Java, write a separate suite that will use standard WordPress API endpoints to verify the site.
  • Also using Java, since I did this recently in a research task at my last job, show how I’d do Selenium-based testing against the site. Use Selenide as the framework for doing this.
  • Version 1 of this project should be a BVT-level thing that will be testing basic front-end things like “are there pages?” and “are there posts?”
  • Version 1 from the API level should be essentially testing the same BVT level things, only querying via REST as opposed to hitting pages on the site.
  • Stretch goal for the front end: a test that verifies you can leave a comment on a previously existing post.

Test Environments

  • Ubuntu, since that was the environment I most often worked with in my last position.
  • Windows 10, with the Ubuntu subsystem installed.

Both of these are installed on Savah, my dev box, which dual boots between those two operating systems.

Additional tools I plan to use:

  • For the Java code, I’ll be using IntelliJ as that’s what I’m most recently familiar with.
  • Within IntelliJ, I’ll be setting it up to run the tests as a TestNG suite, but also through Maven.
  • For the Python, I will also be doublechecking if IntelliJ will let me deal with Python. If it doesn’t, I will be doing one of two things: investigating PyCharm to see if I like it, and failing that, installing Eclipse. (Eclipse was the last thing I worked with in depth for Python code.)
  • For manual verification of any WordPress endpoints I want to play with, I’ll be installing Postman.
  • I will be installing a local instance of Jenkins to demonstrate my familiarity with running automation jobs via that.
  • For Selenium server purposes, I’ll be installing Docker and the official Docker Selenium images. I’ll be experimenting with whether I will do a standalone Chrome or Firefox image, or setting up a grid via Docker-Compose. (Prior experience with researching this suggests it’ll be the latter.)

What I’ll Do With the Code

I’ll be creating the Python and Java projects as two separate repos up on my GitHub account (taking steps to make sure that any information I don’t want to reveal about account credentials doesn’t get included).

I will include documentation. And, time permitting, perhaps a Powerpoint slideshow to talk about it.

More on this as it develops!

My history with test plans

My last position was pretty standard in terms of how testing a project went. Something like this, in a rather loose implementation of Agile methodology:

  1. Project management, Dev, and QA got together to go over a project concept and discuss what it was asking for. Usually, but not always, this would involve reviewing a BRD (“business requirements document”) or a spec. These could involve wireframes from Design, actual mock screenshots, written expectations for how a thing should work, or all or none of the above.
  2. Sometimes in the same meeting, or sometimes in a different meeting, we’d discuss the logistics of how to implement the desired functionality.
  3. Dev and QA would then task out the expected work. I am familiar with using points to scope out the size of a task, but at this particular position, we mostly just scoped tasks as “this will take me X number of hours to do”.
  4. Once we had the tasks, we’d agree who was expected to perform what, and see how long it would take us to accomplish them so we could commit to a release date. Sometimes this would take us just a single two-week sprint, maybe two depending on how long Dev would need before handing off to QA.

Now, as a member of the QA team, it’d be on me to work with the expected plan for how to test things. Usually this plan would be whatever set of tasks we’d committed to for any given sprint, and we’d take care to write out within each task what the expected work would be. These tasks would often be based on the BRD of whatever we were testing.

But for larger projects, particularly ones where we’d need to pull in external help, we’d often write out actual test cases to use for reference. The tool we most often used for this was TestRail.

Why do I mention all of this?

Partly to go into a bit of detail about my most recent experience with testing, so that I can be able to coherently describe it for later interviews. But also because I want to lay the groundwork for how I plan to do a couple of test projects against this very site.

More on that in forthcoming posts.

Let’s get this party started

Last month I was laid off from my last job, where I was an SDET. As of this writing I’ve been spending the last couple of weeks looking for a new position–and as anybody who’s worked in the tech industry goes, interview loops can be pretty involved and detailed.

My problem: I haven’t been in an actual interview loop for nearly ten years. So I’m out of practice answering the sorts of questions such loops will often give you, like, say, “write me a method that’ll return the smallest integer in an array” or “given a list of input integers, how do you see whether a target integer is in that list?”

In my experience these kinds of questions are not usually the sorts of things you’d have used in an actual job situation. But when I’m out of practice with them, it means I look bad during an interview.

So this site is to help me practice my coding skills to keep them in the forefront of my mind, and to have something I can point at for the sake of hiring managers.

I’ve used this dev site before when doing dev work on my main sites, annathepiper.org and angelahighland.com. So I’ve now reset its database, and will be writing a couple of small automation suites to serve as examples of the sorts of things I did on my last position.

More on this to come!