Unexpected PureUnit results

Just starting out? Need help? Post your questions and find answers here.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Unexpected PureUnit results

Post by spikey »

I'm writing some code which could usefully be unit tested, so I thought I'd give PureUnit a go for the first time. I couldn't get my initial test units to work properly so I went back to basics and tried a modified version of the example code from the readme - but I'm not getting the results I'm expecting from that either:

Code: Select all

; Set the options.
; PureUnitOptions(NoUnicode, SubSystem[OpenGl])

; called once on program start
ProcedureUnitStartup startup()
  UnitDebug("Startup...")
EndProcedureUnit

; called once on program end
ProcedureUnitShutdown shutdown()
  UnitDebug("Shutdown...")
EndProcedureUnit

; Here comes our test procedures
ProcedureUnit passingtest()
  
  UnitDebug("passingtest...")
  
  Assert(#True = #True, "This should pass.") 
  
EndProcedureUnit

ProcedureUnit failingtest()
  
  UnitDebug("failingtest...")
  
  Assert(#True <> #False, "If this fails, the world has gone crazy :)")
  
  For i = 1 To 10
    Continue
    Fail("This point should never be reaced")
  Next i
  
  ; here our test will fail.
  Assert(#True = #False, "This is bound to fail!") 
  
EndProcedureUnit
This is the output from the gui log:

Code: Select all

Using compiler: PureBasic 5.71 beta 1 LTS (Windows - x64)

Preparing file: DemoTest.pb
Compiling with: (no parameters)
Compiling with: /UNICODE

Stats: 0 successful tests in 1 files. (0 min, 35 sec)
And this is the log file:

Code: Select all


PureUnit - Test report

Statistics:

    Date: 	06/15/2019 - 12:19:22
    PureUnit Version: 	PureUnit 1.1 - (c) 2016 Fantaisie Software
    Compiler Version: 	PureBasic 5.71 beta 1 LTS (Windows - x64)
    Operatingsystem: 	
    Testfiles: 	1 (1 correct, 0 with errors, 0 skipped)
    Successful tests: 	0
    Failures: 	0
    Parser Warnings: 	0
    Options: 	Resume tests after errors.
    Testing time: 	0 minutes, 34 seconds
    Status: 	All tests completed.


Base Directory:

    P:\Unit Tests\

Correct files:

    DemoTest.pb

This log content is not meeting my expectations however as follows:-

1) The passing test should always work so I'm expecting 2 passes.
2) The 'failingtest' procedure has a static assertion failure (#True = #False), so I'm expecting 2 failures (once in no flags, once in UNICODE).
3) I'm expecting some message content from the failing assert and also the UnitDebug statements in the other procedures.

I've tested this on PB 5.62 32- and 64-bit gui and console and also 5.71B1 64-bit on Windows 7 and I'm getting the same output from all.

Are my expectations correct? Does anyone else's results match/differ to mine?
PureUnit isn't particularly verbose even with the /VERBOSE switch - is there anything else I can do to debug this?
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Unexpected PureUnit results

Post by #NULL »

It seems to work here (linux)

from commandline

Code: Select all

[user]~/purebasic_571_b1/sdk/pureunit>./pureunit --compiler ~/purebasic_571_b1/compilers/pbcompiler /media/user/USB16/pb2016/testpb/pureunittest/test2.pb 
     File: /media/user/USB16/pb2016/testpb/pureunittest/test2.pb
     Line: 35
 Compiled: (no parameters)
     Test: failingtest()
  Message: This is bound to fail!

  Assert(#True = #False) failed!
Stats: Failure after 1 successful tests in 1 files. (0 min, 0 sec)
with gui

Code: Select all

Using compiler: PureBasic 5.71 beta 1 LTS (Linux - x64)

Preparing file: test2.pb
Compiling with: (no parameters)
Debug: Startup...
  Test 1 of 2: passingtest()
Debug: passingtest...
  Test 2 of 2: failingtest()
Debug: failingtest...

File: test2.pb
Line: 35
Compiled: (no parameters)
Test: failingtest()
Message: This is bound to fail!

  Assert(#True = #False) failed!
Debug: Shutdown...

Stats: Failure after 1 successful tests in 1 files. (0 min, 1 sec)
Yours also says '35 sec'. Does it actually take that long?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Unexpected PureUnit results

Post by spikey »

#NULL wrote:It seems to work here (linux).
Yours also says '35 sec'. Does it actually take that long?
It does indeed - which also seems excessive to me too but not having done this before I didn't know if my expectation was unreasonable.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Unexpected PureUnit results

Post by #NULL »

I tried with Windows 10 x64 and it works there too. What options did you use in the pureunit gui? Did you copy the pureunit residents file over? Is the pureunit from the same pb version as the used compiler? Is the pb file actually utf-8 encoded? Maybe Try a directory without spaces in the name? Any special compiler options stored in the pb file? Any anti-virus software? Just guessing :)
User avatar
spikey
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Unexpected PureUnit results

Post by spikey »

Thanks for the hints about compilation times and AV - that put me on the right track...

Turns out it was the anti-virus - apparently it decided to dump my custom configuration, including my list of exceptions and the settings about showing warning messages and writing log entries which is really...

This is the last straw - it has GOT to go! :evil:
Post Reply