-
Notifications
You must be signed in to change notification settings - Fork 393
Run UnitsNet JSON serialization tests on the latest UnitsNet libraries in Nuget #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run UnitsNet JSON serialization tests on the latest UnitsNet libraries in Nuget #423
Conversation
For the serialization test project: If in debug configuration, use the UnitsNet.Serialization project reference. If in release configuration, use the latest version of UnitsNet.Serialization as well as UnitsNet in nuget.
Interesting approach, a couple of thoughts:
Did you look into the resources in #417 regarding side-loading multiple versions of the same library? One "latest" csproj build and one v1.2.2 |
Version="*" will get the latest nuget version so we dont need to change it. I think we also need to add a conditional ProjectReference for the main UnitsNet library for the release configuration. So when in release config, this will catch if the serialization library needs to be updated along with the unitsnet library:
Yes, I looked at the resources in #417 but this solution came into mind. :) |
I'll make another commit later. Then here's how i plan to test it:
I'll let you know the results. :) |
Ah, I think I got it. I do think your thinking is good, but not sure if the code changes will actually work this way. The test project only references the JSON lib and transitively gets the UnitsNet lib, based on what the JSON lib in turn references. So, if I got it right:
|
Adding the conditional ProjectReference for the UnitsNet should solve this. See commit 3bafcab It's the other way around.
|
Aha, yes I got it the wrong way around. So by introducing the extra reference in If I'm not mistaken, we need to run tests against two versions of JSON lib to cover both scenarios:
|
Maybe we can also make the AppVeyor run the tests in Debug config? Also, for the Release config, will it be better to force Assert.Inconclusive (yellow) if the JSON nuget fails? This way, we can easily distinguish it from the branch's code test fails (red). |
I think we can make custom build configurations: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-create-and-edit-configurations So maybe just create a custom configuration (e.g.
|
Hm. I just realized the easiest way to achieve this is to build and run the JSON tests twice. Doesn't really matter if we use Debug/Release, TestJsonNuget or some other way to distinguish - we still need to do the whole build/run tests cycle twice. The only difference is what libraries are linked in. In that light, there is a third option:
The advantage of this is that you only have to "build once" and not mess with build parameters to control this. You simply have two test projects with different references, running the same test code. The new csproj format and the dotnet CLI tooling is a bit icky in terms of sharing source code for two csproj projects.
|
Haha. Yes I agree that will be an easier and better solution. I'll try make another branch and will submit another PR with that solution. :) |
Closing this in favor of #425 |
* Create another test project to run UnitsNet JSON serialization tests on the latest UnitsNet libraries in Nuget The new test project is `UnitsNet.Serialization.JsonNet.CompatibilityTests`. UnitsNetJsonConverterTests.cs is added as a link. ` <Compile Include="..\UnitsNet.Serialization.JsonNet.Tests\UnitsNetJsonConverterTests.cs" Link="UnitsNetJsonConverterTests.cs" />` The project runs the serialization tests on the latest version of the UnitsNet.Serialization.JsonNet library in Nuget. `<PackageReference Include="UnitsNet.Serialization.JsonNet" Version="*" />` * Added xUnit DotNetCliToolReference * Force compatibility tests to use branch's UnitsNet code see #423 (comment) Compatibility test must use JSON Nuget and branch's UnitsNet code * Added compatibility tests project to Start-Tests script function
Fixes #417
The main idea is to use build configuration to switch the UnitsNet reference of the serialization test project:
If in debug configuration, use the UnitsNet.Serialization project reference.
If in release configuration, use the latest version of UnitsNet.Serialization as well as UnitsNet in nuget.
I tested this by changing the Version to "1.2.2" ("*" in the commit). I then ran the build.bat file and it failed on some of the serialization tests as expected.
Hopefully this doesn't conflict with anything in the Appveyor. I'm not really familiar with that tool yet.