Using Team Foundation Server with the Eclipse IDE

Tags

, , , , , , , , ,

The following should be possible with any basic Eclipse installation, but I’ve used Eclipse for Testers with a Python editor add-on. The IDE is freely-available, is highly customisable and can be installed on Linux. With the TFS Plug-in for Eclipse, developers can still use TFS for comms even when they don’t have access to certain editions of Visual Studio or their main developer tools are on a Linux system.

installing-tfs-plugin

Server Connection
Selecting ‘Window > Open Perspective‘ will open the Team Explorer panel to the right of the workspace. As you can see, it’s near identical to the one in Visual Studio. If a Team Foundation Server was accessed from the local system before, the server address(es) will be listed when the Connect to Team Projects icon is clicked.

eclipse-team-explorer

Version Control #2
Eclipse and the TFS plug-in also provide the version control features outlined in my last post. Developers can see the source changes on the TFS server and the file histories, but can they upload changes to the server? After all, the whole point of TFS is communication, right?
To find out, I created a new project in Eclipse, and a text file within it called ‘testFromEclipse.txt‘. For this you’ll need the Project Explorer view (‘Window > Show View > Other‘).

eclipse-project-explorer

To get a saved project onto the server, we right-click the top entry in the Project Explorer, then select ‘Team > Share Project…‘. Follow the next dialogue options, ensuring the project is loaded into the correct location on the server.

eclipse-share-project

The resulting changes will then appear in the Team Explorer panel. We get a list of Included Changes and Excluded Changes, plus the Check In button.

eclipse-pending-changes

It might be a good idea to check the TFS web portal to ensure the changes were uploaded from the IDE.

eclipse-web-portal

We could also check whether the project and its change history are available through the Source Control Explorer in Visual Studio.

Changes as Features
Changes can be annotated in the web portal by visiting the Changesets page under the CODE tab. Here comments can be added to the ‘solution’ or any of the project files, so others know what changes were made.
Add the comment, and click the icon next to it to create a new feature. This will be added to the Features list in the TFS backlog.

changeset-comment

tfs-feature

Cleaning Up
We might want to remove the test project from the server. The easiest way of doing this is within Visual Studio. Simply delete the project entry in the Source Control Explorer and that becomes a pending change that must be ‘checked in’.

Setting up Version Control

Tags

, , , , ,

When multiple developers are working on the same thing, change tracking and attribution becomes important, as does the option to replace broken projects with an earlier and definitive versions.
The Git system has become a really popular version control solution. It’s not limited to any platform, and a team requires only the right software and network-mounted filesystem. Commonly GitHub is used as a ‘master’ repository for large open source projects.
The client for Windows includes a Bash command line and a GUI-based application. After it’s installed, it needs a repository location, which could be a local directory. A repository isn’t much use without something to push code changes to it. Thankfully, Microsoft released a lightweight editor called ‘Visual Studio Code‘ that includes a Git feature.

Using Visual Studio Code, I created a new file in the repo directory. As you can see, there is a little indicator on the Git side panel button, indicating there is one change to ‘commit’. There is also a small ‘U‘ sign showing the change is untracked, and a plus icon to stage the change.

create-change

If multiple developers are pushing files to the same repo, they might be listed here also. Another useful feature of VS Code is the editor can be split, so the current source can be compared with a previous version.

vs-code-compare

To stage an item, click the ‘plus’ icon. When the ‘Rescan‘ button is clicked in the Git application, the list of Staged and Unstaged changes will be updated.
A ‘commit’ is accompanied by a short message containing a short description and reason for the change, which are visible in whatever history.

Viewing Change History
This is possible using the Git GUI application, which could be running on another developer’s system that’s reading the repository.

Click Repository > Visualise master’s history. This will bring up the following interface:

view-master-history

Here we can revert changes and view the commit messages.

Team Foundation Server Walkthrough
Although it’s possible to use Visual Studio and TFS with Git, Microsoft has its own version control system. Before doing anything, the project should be created on the TFS. This can be done within Visual Studio’s by creating a ‘New Team Project‘, or by signing into the TFS web portal and creating it there.

With that set up, we can create the Visual Studio project itself. In this example it’s simply a C# form with a text box and button. If an existing project is being added to a repository, I strongly recommend keeping a back up elsewhere.
When done, save the project, right-click on the top level entry in Solution Explorer, and select ‘Add Solution to Source Control‘. We’re presented with a choice between TFS Version Control and Git. The next window after that is where we can choose which TFS folder the solution files are uploaded to.

select-tfs-folder

However, the project files aren’t simply uploaded to the server. They must be ‘checked in’, following a similar process to Git. Add a comment and click the ‘Check In‘ button in the Team Explorer window. At this point, the source files are uploaded, as are any subsequent changes.

team-explorer-check-in

The source files and their histories are now available to other developers using the server.

vso-history

The useful thing about the TFS system is the other developers can view each others’ work within their own Visual Studio installations, without having to go through the portal. Plus TFS enables the server admin to set really granular permissions for the team members.

source-control-list

visual-studio-project-history

Where Would a Repeal of the Human Rights Act Take Us?

Tags

, , , , , , , , ,

On the surface, the Tories’ plan to repeal the Human Rights Act seems insane, ethically problematic at best. The Human Rights Act was one of New Labour’s greatest achievements, and if nothing else, it was symbolic of the UK’s commitment to fairness and basic human decency, so what possible justification could there be for undoing that?
The Tories are planning something a little more complex than repeal. It involves ultimately replacing the Human Rights Act with a ‘Bill of Rights and Responsibilities’ that’s expected to contain the text of the original Convention on Human Rights. The government will then take that Bill to the European Council on Human Rights, and if it’s rejected the UK will withdraw from the ECHR. Confusing, no?

The important question is why? Clearly there must be differences between the Human Rights Act and the proposed Bill of Rights that warrant such a proposal, even if both apparently have the same text. Yes, it’s been argued the law should change to allow the deportation of foreign criminals, but that particular issue seems too insignificant to be the real motive. It is certainly not a strong enough reason to repeal the HRA.

The HRA is largely about setting a standard of fairness, welfare, decency and duty of care, whereas a typical bill of rights is concerned with protecting the rights of individuals against the state. The other difference is the term ‘Bill of Rights’ implies something that’s not so legally binding, and I honestly don’t see how it could be upheld. Perhaps it’s not supposed to be upheld, but instead over-ruled by politicians whenever it proves inconvenient.

My next question is whether the ultimate aim is a withdrawal from the European Convention on Human Rights, using the Bill of Rights as a means to achieve that, and a weakening of the protections. The answer to this is hinted at in Chris Grayling’s ‘report’, which should be read as a business case for the repeal. It talks of limiting the use of the HRA to ‘serious cases’ and ‘tackling the misuse of rights’. What exactly is meant by this? My (limited) understanding is the European Convention on Human Rights and the HRA outlines what the law is, and it’s English law that determines how the HRA is interpreted. In other words, it’s the British courts, not politicians, who currently decide whether the HRA is being ‘misused’.

It’s also not certain the HRA can be repealed. The first obstacle would likely be most MPs, including an unknown number of Conservatives, voting against it in Parliament. Supposing it does get through the House of Commons, the House of Lords could also prevent the repeal. Even if the House of Lords are under an obligation to pass whatever law was mentioned in the Conservatives’ manifesto (the Salisbury Convention), the issues of human rights and the HRA are fundamental enough to be an exception, plus it would require a satisfactory Bill of Rights to be submitted first.

Team Foundation Server Administration

Tags

, , , , , , , ,

Team Foundation Server is something I’ve come across only fairly recently while getting stuck into Microsoft’s enterprise developer stuff, and I decided to play around with my own personal installation. Anyone can download the Express edition or register an account with visualstudio.com to access the managed service.
TFS is primarily an extension of Visual Studio, something that connects a project team’s developer tools to a central collaboration server.

tfs-server-client

In our case, we use it partly for ‘regression testing’ where different teams are involved in the continual patching and testing of applications. It’s also being used for code reviews, where projects are uploaded straight from Visual Studio to TFS.

Installation and Setup
On installation, the Team Foundation Server Administration Console is made available. One of the first steps is to start the Build Configuration ‘wizard’. This sorts the installation and basic server features (authentication, controllers, backups, etc.) that enable it to run.

tfs-admin-console

The initial ‘Team Project Collections‘ can be created to segregate the developer teams’ projects, but apart from that, the user interface applications are required for managing the projects themselves. The Administration Console is also required for removing TFS ‘collections’.

So, what could be done with this? How is it useful? Well, this is where the web portal, Visual Studio and Microsoft Test Manager are used. A small team will find itself juggling between the three a lot, even though they’re part of the same thing here.

The Web Portal
TFS Express provides a limited version of the portal users get with the full version and visualstudio.com. In particular, the Express version doesn’t have the testing features. The portal is hosted using IIS, so the Internet Information Services Manager is also installed on the system.

Connect to the local TFS web portal at http://localhost:8080/tfs. The following screen will appear.

web-portal-full-features

After projects have been uploaded from Visual Studio, they can be managed in the web portal. As you can see, there are sections laid out following the typical software development workflow, from design to testing.

Active Directory
While running the server Build Configuration, there is the option to set Kerberos or NTLM as the authentication method and use the developers’ Active Directory accounts. This also enables the TFS administrator to add users from whatever domain the server is on.

Creating Projects
For some reason, this must be done within the Team Explorer window in Visual Studio and in the Test Manager application, obviously by the person designated as the project admin. Click the drop-down near the top, and create the new project under the ‘Projects and Teams‘ option. Visual Studio then downloads the project templates for creating the new project.
With this done, the full Team Explorer menu options are enabled, and the Visual Studio environment and Microsoft Test Manager can be used for connecting to the server.

team-explorer-new-3

The full project features also become available in the web portal, which is actually called ‘Team Web Access‘.

Existing projects in Visual Studio can be added to TFS, by entering the Source Control Explorer (within Team Explorer), creating a new folder and adding items to it. To make the project available, the code must be ‘checked in’.
Right-click on the project folder in Source Control Explorer, and select ‘Check In Pending Changes‘. In the Team Explorer, add a comment and click the ‘Check In‘ button.

tfs-check-in-1

The project will appear in the web interface.

tfs-published-test-project2

Microsoft Test Manager Application
For the life of me I can’t remember how this got installed on my laptop. Maybe it came with Visual Studio. Microsoft Test Manager is an independent application that functions as another front-end to TFS. What you can do with this is access the stored test scripts and launch them as a side panel while the tested application is running. It doesn’t do much with TFS Express.

lab-center

This is just a basic overview of getting started. There are many other features that can be of use in project management, and I think it’ll be more widely used by developer teams over the coming years. It’s worth installing TFS Express and getting as much exposure to it as possible.

Batch Scripting for a Quiet Weekend

Tags

, , , , , , , ,

Last week I was tasked with finding out whether automated test runs can be scheduled, so they can be started without anyone being in the office. A few minutes research told me a few others were stuck on this problem. There was the option of using MSTest to run a set of projects from a list, but Visual Studio 2013 replaces this feature with a ‘Playlist’, and unfortunately there isn’t a way of directly launching this from outside the IDE. Well, the following is a little workaround that I hope others would find useful.

The Visual Studio installation includes a command line program called vstest.console.exe, which (to my surprise) is capable of reading the test script instructions from a project DLL. It is found at C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe.
With a little setting up, it’s possible to use the Windows Task Scheduler to launch this. It’s awkward if you want it to launch a sequence of projects, though, so we also need a batch script.

First, create a container directory and copy the DLL files (/bin/release or /bin/debug) for each project into it.

test-dll-folder

Then create the batch script to start vstest.console.exe and point it to the DLLs. Although the script could probably be written straight into the Task Scheduler, most people would want to re-use it for other things. It should look something like this:

test-batch-script

All that remains is to configure the Windows Task Scheduler to run the batch script at a pre-determined time.

task-scheduler-test

It does actually work while the computer is ‘sleeping’, and the computer will remain locked. When done, the output normally displayed in Visual Studio’s Test Explorer window will be dumped to a file in the container directory.

scheduled-test-log

Follow

Get every new post delivered to your Inbox.

Join 25 other followers