0

Our product (C++ windows application, Google Test as testing framework, VS2015 as IDE) has a number of file-based interfaces to external products, i.e., we generate a file which is then imported into an external product. For testing these interfaces, we have chosen a golden file approach:

  1. Invoke the code that produces an interface file, save the resulting file for later reference (this is our golden file - we here assume that the current state of interface code is correct).
  2. Commit the golden file to the TFS repository.
  3. Make changes to the interface code.
  4. Invoke the code, compare the resulting file with the according golden file.
  5. If the files are equal, the test passes (the change was a refactoring). Otherwise,
  6. Enable the refresh modus which makes sure that the golden file is overriden by the file resulting from invoking the interface code.
  7. Invoke the interface code (thus refreshing the golden file).
  8. Investigate the outgoing changes in VS's team explorer. If the changes are as desired by our code changes from step 3, commit code changes and golden file. Otherwise, go back to step 3.

This approach works great for us, but it has one drawback: VS only recognizes that the golden files have changed (and thus allows us to investigate the changes) if we use a local workspace. If we use a server workspace, programmatically remove the read-only flag from the golden files and refresh them as described above, VS still does not recognize that the files have changed.

So my question is: Is there any way to make our golden file testing approach work with server workspaces, e.g. by telling VS that some files have changed?

csoltenborn
  • 1,127
  • 1
  • 12
  • 22

1 Answers1

1

I can think of two ways.

First approach is to run a tf checkout instead of removing the Read-Only attribute. This has an intrinsic risk as one may inadvertently checking-in the generated file; this should be prevented by restricting check-in permissions on those files. Also you may need to run tf undo to clean up the local state.

Another approach would be to map the golden files in a different directory and use a local diff tool instead of relying on Visual Studio builtin tool. This is less risky than the other solution, but may be cumbersome. Do not forget that you can "clone" a workspace (e.g. Import Visual Studio TFS workspaces).

Community
  • 1
  • 1
Giulio Vian
  • 8,248
  • 2
  • 33
  • 41
  • Thanks for your suggestions! I just tried the "tf checkout" option: I programmatically generated an according command '"C:\Program Files (x86)\.....\IDE\tf.exe" checkout ""' and executed it with 'system(Command)'. However, this always returns 1, and the golden file can still not be overridden. If I execute the very same command in the console, it works just fine, and my test code can afterwards override the golden file (and the outgoing change is shown within team explorer). Do you have any idea where the difference between the two approaches is, by any chance? – csoltenborn Oct 30 '15 at 14:00
  • <<< executed it with 'system(Command)' >>> you mean that the command is run by LocalSystem user? Avoid if possible, it is a very peculiar context, but explaning all the nuances deserve another question (and you can find many answers in SO already). – Giulio Vian Oct 30 '15 at 14:13