Unit tests Silver

Hey I am completely new here,
I am trying to play around with silver on windows a little. But I have no idea how to setup EUnit, if I just make class in the WPF application, it does not know RemObjects.Elements.EUnit namespace, and if I make the whole EUnit project, it does not know withListener. Did I screwed up setup somewhere on the way?

thanks

Filip,

the idea would-be that you create two projects — your real app, and a test project (which references EUnit.dll which in turn gives you the RemObjects.Elements.EUnit namespace). You then share the code you want to test between the two projects — either reference your main project from the test project, or just add the same code files to both.

—marc

Hey,
so I have RemObjects.Elements.EUnit in the list of references in my test project, but I am still getting Unknow identifier on withListener here
Runner.RunTests(lTests) withListener(ConsoleTestListener())`

Filip

What language?

Runner.RunTests(lTests) withListener(new ConsoleTestListener())

works for C# and Oxygen, but for Swift to would be

Runner.RunTests(lTests, withListener: ConsoleTestListener())

since Swift does the secondary parameters inside the parenthesis.

I notice that is indeed broken in our template. fixing now. You will also need to manually set Copy Local on the Swift, Sugar and EUnit references to True, that’s another template bug i just fixed. My apologies for that.

1 Like

Hey,
that did it. I just made new EUnit project, and the file has .swift extension but it was the code for C# and Oxygen.

thank you
Filip

And one more question,
so I wrote first test, I run it, console pops up and its gone in a split second. How can I see the results? Is there a way to see classic red/green bar?

I am using visual studio .

thanks

You can add a Console.ReadLine() or something along those lines the the Program.swift file, to keep the console window open after it finishes running. Unfortunately Windows closes console windows immediately after the process exits :frowning:

Right now, EUnit only has the console-mode viewer, no GUI viewer yet — although that is on the list.

thanks, that did the trick, I was just not sure where to put the Console.Realine() :wink:
and now I just need to figure out which Discovery method to use, because right now I am getting 0 tests even that there should be 1, so Discovery is not discovering. I can not find any examples on this .

Hmm. The default mode should work as is. Can you post your project so that we can have a look?

We will be providing more examples and docs for EUnit soon, hopefully.

Hi,
so I got it working, my problem was at first that template generated something like this

public class TestCalculator{...}

and it took me a while to find the example that said that I need to extend class Test, also I got confused because I was trying to fit it to this syntax http://docs.elementscompiler.com/API/EUnit/Test_Class/ first but now it is working, although it is for some reason finding one test more that I am not aware of.

Oops, my apologies again. i’ve fixed the template to include the proper ancestor, now.

i believe that’s a known issue, it’s counting the test suite itself as a testcase. We’ll be fixing that as well.

—marc