Quick Links

Recent Changes

    27.11.2019 - Networking Event 2019.2: End-to-End Web Testing

    Richi presented the requirements for and history of end-to-end testing, from Selenium to the more modern, flexible and fast solutions we use at Encodo, like Cypress and TestCafé.

    14.11.2019 - Improving NUnit integration with testing harnesses

    imageThese days nobody who's anybody in the software-development world is writing software without tests. Just writing them doesn't help make the software better, though. You also need to be able to execute tests -- reliably and quickly and repeatably.

    That said, you'll have to get yourself a test runner, which is a different tool from the compiler or the runtime. That is, just because your tests compile (satisfy all of the language rules) and could be executed doesn't mean that you're done writing them yet.

    Testing framework requirements

    Every testing framework has its own rules for how the test runner selects methods for execution as tests. The standard configuration options are:

    • Which classes should be considered as test fixtures?
    • Which methods are considered tests?
    • Where do parameters for these methods come from?
    • Is there startup/teardown code to execute for the test or fixture?

    Each testing framework will offer different ways of configuring your code so that the test runner can find and execute setup/test/teardown code. To write NUnit tests, you decorate classes, methods and parameters with C# attributes.

    The standard scenario is relatively easy to execute -- run all methods with a Test attribute in a class with a TestFixture attribute on it.

    Test-runner Requirements

    There are legitimate questions for which even the best specification does not provide answers.

    When you consider multiple base classes and generic type arguments, each of which may also have NUnit attributes, things get a bit less clear. In that case, not only do you have to know what NUnit offers as possibilities but also whether the test runner that you're using also understands and implements the NUnit specification in the same way. Not only that, but there are legitimate questions for which even the best specification does not provide answers.

    At Encodo, we use Visual Studio 2015 with ReSharper 9.2 and we use the ReSharper test runner. We're still looking into using the built-in VS test runner -- the continuous-testing integration in the editor is intriguing1 -- but it's quite weak when compared to the ReSharper one.

    So, not only do we have to consider what the NUnit documentation says is possible, but we must also know what how the R# test runner interprets the NUnit attributes and what is supported.

    Getting More Complicated

    Where is there room for misunderstanding? A few examples,

    • What if there's a TestFixture attribute on an abstract class?
    • How about a TestFixture attribute on a class with generic parameters?
    • Ok, how about a non-abstract class with Tests but no TestFixture attribute?
    • And, finally, a non-abstract class with Tests but no TestFixture attribute, but there are non-abstract descendants that do have a TestFixture attribute?

    In our case, the answer to these questions depends on which version of R# you're using. Even though it feels like you configured everything correctly and it logically should work, the test runner sometimes disagrees.

    • Sometimes it shows your tests as expected, but refuses to run them (Inconclusive FTW!)
    • Or other times, it obstinately includes generic base classes that cannot be instantiated into the session, then complains that you didn't execute them. When you try to delete them, it brings them right back on the next build. When you try to run them -- perhaps not noticing that it's those damned base classes -- then it complains that it can't instantiate them. Look of disapproval.

    Throw the TeamCity test runner into the mix -- which is ostensibly the same as that from R# but still subtly different -- and you'll have even more fun.

    Improving Integration with the R# Test Runner

    At any rate, now that you know the general issue, I'd like to share how the ground rules we've come up with that avoid all of the issues described above. The text below comes from the issue I created for the impending release of Quino 2.

    Environment

    • Windows 8.1 Enterprise
    • Visual Studio 2015
    • ReSharper 9.2

    Expected behavior

    Non-leaf-node base classes should never appear as nodes in test runners. A user should be able to run tests in descendants directly from a fixture or test in the base class.

    Observed behavior

    Non-leaf-node base classes are shown in the R# test runner in both versions 9 and 10. A user must navigate to the descendant to run a test. The user can no longer run all descendants or a single descendant directly from the test.

    Analysis

    Relatively recently, in order to better test a misbehaving test runner and accurately report issues to JetBrains, I standardized all tests to the same pattern:

    • Do not use abstract anywhere (the base classes don't technically need it)
    • Use the TestFixture attribute only on leaf nodes

    This worked just fine with ReSharper 8.x but causes strange behavior in both R# 9.x and 10.x. We discovered recently that not only did the test runner act strangely (something that they might fix), but also that the unit-testing integration in the files themselves behaved differently when the base class is abstract (something JetBrains is unlikely to fix).

    You can see that R# treats a non-abstract class with tests as a testable entity, even when it doesn't actually have a TestFixture attribute and even expects a generic type parameter in order to instantiate.

    Here it's not working well in either the source file or the test runner. In the source file, you can see that it offers to run tests in a category, but not the tests from actual descendants. If you try to run or debug anything from this menu, it shows the fixture with a question-mark icon and marks any tests it manages to display as inconclusive. This is not surprising, since the test fixture may not be abstract, but does require a type parameter in order to be instantiated.

    image

    Here it looks and acts correctly:

    image

    I've reported this issue to JetBrains, but our testing structure either isn't very common or it hasn't made it to their core test cases, because neither 9 nor 10 handles them as well as the 8.x runner did.

    Now that we're also using TeamCity a lot more to not only execute tests but also to collect coverage results, we'll capitulate and just change our patterns to whatever makes R#/TeamCity the happiest.

    Solution

    • Make all testing base classes that include at least one {{Test}} or {{Category}} attribute {{abstract}}. Base classes that do not have any testing attributes do not need to be made abstract.

    Once more to recap our ground rules for making tests:

    • Include TestFixture only on leafs (classes with no descendants)
    • You can put Category or Test attributes anywhere in the hierarchy, but need to declare the class as abstract.
    • Base classes that have no testing attributes do not need to be abstract
    • If you feel you need to execute tests in both a base class and one of its descendants, then you're probably doing something wrong. Make two descendants of the base class instead.

    When you make the change, you can see the improvement immediately.

    image


    1. ReSharper 10.0 also offers continuous integration, but our experiments with the EAP builds and the first RTM build left us underwhelmed and we downgraded to 9.2 until JetBrains manages to release a stable 10.x.

    14.11.2019 - Encodo New Year's Game 2013 Tips & Tricks

    At the end of last year, Encodo shipped a little JRPG-style game to customers and partners. JRPG stands for "Japanese Role-Playing Game" and is usually shown in a top-down or isometric view.

    Our version uses Jaws, a low-level, open-source, Javascript game engine but, after some research into alternatives, we ended up writing most of the logic and rendering in our own layer on top of it. We tried to keep the code relatively clean and tested it on most desktop and mobile browsers.

    Our game takes place in our office here in Winterthur and features all of the Encodo employees. Quoting from the game:

    In order to get a surprise this coming spring, there are a few tasks you'll have to perform. Each employee has a piece of the solution that you can earn either by answering their questions or by bringing them an object that they lost or that they would like.

    You finish the game when you've collected all of the puzzle pieces that you get by answering each employee's questions -- or by giving them an object that they want. The puzzle pieces fit together to reveal a message.

    image image image image

    You can play the game by browsing to the Encodo RPG 2013; it's available in English and German. You're only eligible for a gift if we sent you a card with a code on it, but you can still send us a message at the end if you finish the game.

    Once you get past the intro screen and some instructions, you're dropped into the game and can start to look around. In the top-left corner is the table on which you'll find all of the different items that you can use in the game -- and that you can use to "convince" employees to give you their puzzle piece if you can't answer their questions.

    As you play, the game keeps track of "points" as well as progress. In order to get 100% progress and complete the game, you have to get each employee's puzzle piece. The number of points you have at the end reflects how efficiently you did this.

    • You lose points for each incorrect answer
    • You gain more points for a correct answer than by trading an item for the puzzle piece
    • You can earn extra points by finding secrets, hinted at in the instructions that "[y]ou can also interact with other parts of the office"
    • If you need more help finding secrets, try turning off the lights (as shown in "Encodo at Night"); not only are employees highlighted, but so are a few other places (including the light switch ;-).
    • Sometime just activating the secret isn't enough; sometimes you need a specific object1 in order to find the secret.
    • You can check your progress toward completing the puzzle at any time by pressing F1 or H or by pressing the "help" icon in the top-right corner (as shown in "Help Screen").
    • You can skip the instructions at the beginning by pressing "Esc"

    And, in case you don't finish it, we'd like to give credit where credit is due:


    | Credits |

    Story

    Marco von Ballmoos
    Remo von Ballmoos
    Daniel Roth

    Programming

    Armin Bilibani
    Stephan Hauser
    Daniel Roth
    Pascal Stählin
    Marco von Ballmoos

    Graphics

    Armin Bilibani
    Stephan Hauser

    Music

    Derris-Kharlan

    Powered by Jaws and Encodo RPG Engine



    1. Spoiler alert: the items you can use to find secrets are the SSD and the cappuccino. (Select the text to reveal the answer.)

    12.11.2019 - Improving WebPack Performance

    This is a WintiWebDev talk about optimizing WebPack configurations for TypeScript/React/Less applications

    17.10.2019 - Azure Linked Accounts and SSH Keys

    Azure DevOps allows you to link multiple accounts.

    Our concrete use case was:

    • User U1 was registered with an Azure DevOps organization O1
    • Microsoft did some internal management and gave our partner account a new organization O2, complete with new accounts for all users. Now I have user U2 as well, registered with O2.
    • U2 was unable to take tests to qualify for partner benefits, so I had to use U1 but link the accounts so that those test results accrued to O2 as well as O1.
    • We want to start phasing out our users from O1, so we wanted to remove U1 from O1 and add U2

    Are we clear so far? U1 and U2 are linked because reasons. U1 is old and busted; U2 is the new hotness.

    The linking has an unexpected side-effect when managing SSH keys. If you have an SSH key registered with one of the linked accounts, you cannot register an SSH key with the same signature with any of the other accounts.

    This is somewhat understandable (I guess), but while the error message indicates that you have a duplicate, it doesn't tell you that the duplicate is in another account. When you check the account that you're using and see no other SSH keys registered, it's more than a little confusing.

    Not only that, but if the user to which you've added the SSH key has been removed from the organization, it isn't at all obvious how you're supposed to access your SSH key settings for an account that no longer has access to Azure DevOps (in order to remove the SSH key).

    Instead, you're left with an orphan account that's sitting on an SSH key that you'd like to use with a different account.

    So, you could create a new SSH key or you could do the following:

    • Re-add U1 to O1
    • Remove SSH key SSH1 from U1
    • Register SSH key SSH1 with U2
    • Profit

    If you can't add U1 to O1 anymore, then you'll just have to generate and use a new SSH1 key for Azure. It's not an earth-shatteringly bad user experience, but interesting to see how several logical UX decisions led to a place where a couple of IT guys were confused for long minutes.

    17.10.2019 - Visual Studio 2019 Survey

    Visual Studio 2019 (VS) asked me this morning if I was interested in taking a survey to convey my level of satisfaction with the IDE.

    VS displays the survey in an embedded window using IE11.1 I captured the screen of the first thing I saw when I agreed to take the survey.

    I know it's the SurveyMonkey script that's failing, but it's still not an auspicious start.



    1. I'd just upgraded to Windows 10 build 1903, which includes IE 11.418.18362.0. I can't imagine that they didn't test this combination.

    17.10.2019 - Using Git efficiently: SmartGit + BeyondCompare

    I've written about using SmartGit (SG) before1 2 and I still strongly recommend that developers who manage projects use a UI for Git.

    If you're just developing a single issue at a time and can branch, commit changes and make pull requests with your IDE tools, then more power to you. For this kind of limited workflow, you can get away with a limited tool-set without too big of a safety or efficiency penalty.

    However, if you need an overview or need to more management, then you're going to sacrifice efficiency and possibly correctness if you use only the command line or IDE tools.

    I tend to manage Git repositories, which means I'm in charge of pruning merged or obsolete branches and making sure that everything is merged. A well-rendered log view and overview of branches is indispensable for this kind of work.

    SmartGit

    I have been and continue to be a proponent of SmartGit for all Git-related work. It not only has a powerful and intuitive UI, it also supports pull requests, including code comments that integrate with BitBucket, GitLab and GitHub, among others.

    It has a wonderful log view that I now regularly use as my standard view. It's fast and accurate (I almost never have to refresh explicitly to see changes) and I have a quick overview of the workspace, the index and recent commits. I can search for files and easily get individual logs and blame.

    The file-differ has gotten a lot better and has almost achieved parity with my favorite diffing/merging tool Beyond Compare. Almost, but not quite. The difference is still significant enough to justify Beyond Compare's purchase price of $60.

    What's better in Beyond Compare3?

    Diffing

    • While both differs have syntax-highlighting (and the supported file-types seem to be about the same), Beyond Compare distinguishes between significant and insignificant (e.g. comments) changes. It makes it much easier to see whether code or documentation has changed.
    • The intra-line diffing in Beyond Compare is more fine-grained and tends to highlight changes better. SmartGit is catching up in this regard.
    • You can re-align a diff manually using F7. This is helpful if you moved code and want to compare two chunks that the standard diff no longer sees as being comparable

    Merging

    I could live without the Beyond Compare differ, but not without the merger.

    • The 4-pane view shows left, base and right above as well as the target below, with the target window being editable. Each change has its own color, so you can see afterwards whether you took left, right or made manual changes.
    • The merge view includes a line-by-line differ that shows left, base, right and target lines directly above one another, with a scrollbar for longer lines.
    • The target view is color-coded to show the origin of each line of text: right, left, base or custom edited.
    • BeyondCompare makes a smart recommendation for how to merge a given conflict that is very often exactly what you want, which means that for many conflicts, you can just confirm the recommendation.
    • SmartGit has two separate windows for base vs. left/right and right/left vs. target. Long lines are really hard to decipher/merge in SmartGit

    Integrate Beyond Compare into SmartGit

    To set up SmartGit to use Beyond Compare

    1. Select Tools > Diff Tools
    2. Click the "Add..." button
    3. Set File Pattern to *
    4. Select "External diff tool"
    5. Set the command to C:\Program Files (x86)\Beyond Compare 4\BCompare.exe
    6. Set the arguments to "${leftFile}" "${rightFile}"
    7. Select Tools > Conflict Solvers
    8. Select "External Conflict Solver"
    9. Set File Pattern to *
    10. Set the command to C:\Program Files (x86)\Beyond Compare 4\BCompare.exe
    11. Set the arguments to "${leftFile}" "${rightFile}" "${baseFile}" "${mergedFile}"


    1. In Git: Managing local commits and branches (December 2016) and Programming in the modern/current age (February 2013)

    2. I am in no way affiliated with SmartGit.

    3. I am in no way affiliated with BeyondCompare.

    17.10.2019 - Multi-language web sites

    Why are multi-language web sites so hard to make? Even large companies like Microsoft, Google and Apple regularly send content with mixed-language content.

    This is probably due to several factors:

    1. Large web sites pull data for myriad sources, including CDNs and caching services. Each source needs to respect the requested language, If a source doesn't have support for a requested language, then just that piece of content will be delivered in the fallback format.
    2. Any proxies have to pass the requested language (and other headers) on to the backing server. If the backing server doesn't get the language request, then it can't respect the requested language, obviously.
    3. Any proxy that caches content has to respect the language header (as well as any other data-relevant headers) instead of just caching one copy per URL. While this is standard for commercial proxies and CDNs, it might not be the case for bespoke software.
    4. Some services might have a different context (e.g. logged-in user, detected via token in the request), who has different language settings than the requesting browser. This would mean that, while the main page content is pulled from the server with one language (e.g. en-US), the content for an embedded block might be requested as a logged-in user who has a different preferred language (e.g. de-CH). The server will likely honor the preferred language of the user account rather than the language included in the request, assuming it even even gets the language from the original request.
    5. Finally, Some companies1 are notoriously bad at multi-language software because they generally only acknowledge English and consider supporting other languages as a nice-to-have and that delivering English instead is an acceptable fallback because everyone can read English, right?

    The move to cloud-based and highly cached content has increased complexity considerably. Even if a company does everything right in (1), (2), and (3) above, the realities of (4) may still lead to a page that contains content in multiple languages.

    That is, each piece of software is functioning as designed but combining the output from those pieces of software leads to content that has multiple languages in it. At that point, you can either throw your hands in the air and give up...or you can start to redesign services to respect that requested language even if the user context's preferred language is different. This is not a decision you can make lightly and you run the risk of breaking the service's content in other places. Sometimes there is no right answer.

    Since I live in Switzerland, which has 4 official languages, I've seen EULAs from Apple written in a combination of French, English, German and even a word or two of Italian.

    The example below comes from Microsoft Edge's Tips page that they show when you start using the browser. Edge thinks that my default language is German despite the fact that my Windows is English. Microsoft tends to use the language of the region you're in (Switzerland) rather than the display language that you've expressly set, but...that's another discussion.

    At any rate, Edge thinks I want German content2 but Microsoft can't even reliably deliver German content for this main page, defaulting to English content in several places.



    1. I'm looking at you, US companies.

    2. I quickly checked the settings and could not find out how to change the list of languages I'd like to include in my browser requests. Other browsers do provide a list of accepted languages, but Edge's settings are quite limited.

    26.8.2019 - Reinforcements! (2)

    We are happy to welcome Joel Widmer and Matteo Bossi to our team!

    Joel will be reinforcing our Software-Developer section as well as Matteo as our new Software-Developer apprentice.

    17.7.2019 - How to use Authenticated NuGet Feeds

    Much of Encodo's infrastructure is now housed in Azure. Each employee has an account in Azure.

    From Visual Studio

    Because users are already authenticated in Visual Studio (to register it), they will be able to access Azure NuGet feeds through Visual Studio without any further intervention. You can restore/install/update without providing any additional credentials.

    From the Command Line

    As of today, access to Azure Feeds from the command line is granted only if you provide credentials with the source.

    Sources created in the Visual Studio UI do not include credentials.

    Solutions that include sources in a NuGet.config do not have credentials (because they are stored in the repository).

    Therefore, you must register a NuGet source with authentication for Azure for your user.

    Personal Nuget.Config

    You can find your NuGet.config in your roaming profile on Windows, at C:\Users\<username>\AppData\Roaming\NuGet\NuGet.Config.

    Instead of editing the file directly, use the NuGet command line to add an authenticated source.

    Create a Personal Access Token (PAT)

    You cannot just use your username/password to create an authenticated source. Instead, you have to use a PAT.

    Follow the instructions below to create a PAT for your Azure account.

    • Log in to Azure
    • From the user settings (top-right), select Security
    • Select "Personal access tokens" in the list on the left
    • Press the "New Token" button at the top-left of the list
    • Name it NuGet Feed Access
    • Leave the organization at the default (encodo for employees)
    • Set the expiration to something reasonable.
      • 90 days is probably OK.
      • You can choose up to a year.
      • You can update the expiration date at a later time.
    • Select Custom defined for Scopes
    • Click the "Show all scopes" link at the bottom of the dialog (above the "Create" button)
    • Scroll down to "Packaging" and select "Read"
    • Press "Create" to add the token
    • Copy the token immediately. It will never be shown again.
    • Store the token somewhere safe (a password manager is a good idea). If you forget it, you'll have to regenerate the token.

    Some extra tips:

    • Set up a reminder in your calendar for when your PAT is about to expire
    • You can change the expiration date for the token even after you've created it

    Add an Authenticated NuGet Source

    Now you can set up a NuGet source for your user.

    Execute the following command, replacing the bracketed arguments as follows:

    • <username>: your own user name (e.g. <bob@encodo.ch>)
    • <PAT> the PAT you generated above
    • Change the URL for a feed other than Quino
    nuget sources add -Name "Azure (Authenticated)" -Source https://encodo.pkgs.visualstudio.com/_packaging/Quino/nuget/v3/index.json -UserName <username> -Password <PAT>