Category Archives: שאַרעפּאָינט אָנליין

שלעכט עקססיטינג אַנאַונסמענט

Making announcements isn’t really my thing, but this time, I’m really and truly excited about the just-launched Slalom Big Apple SharePoint site. 

I work at Slalom consulting and manage the Portals & Collaboration practice.  The Big Apple site is “my” site for my practice here in New York.  I’ve long wanted one of these. I’m sure that many SP pro’s have wished for something similar.  How many times have we looked at our own company’s public site, or one of customers and seen them building it out and just knowing and wishing that they’d build it on SP?  We all know that SP is pretty good at this kind of thing, but it’s not very common. 

געזונט, the worlds finally aligned just right for me – SP Online is really inexpensive, I had the right team and enough time to actually do it.

It was an amazing journey to get to launch and and some of that is shared up there on the site.

Read all about it here and if you’re interested in the details behind it, I’m more than happy to talk about it.

Here is the official announcement link: http://www.bigapplesharepoint.com/pages/View-An-Insight.aspx?BlogID=82 #O365

</עק>

ווי צו: קאַנפיגיער יוניט פּרובירן און פּרובירן קאַווערידזש מיט קווניט.דזשס און בלאַנקעט.דזשס פֿאַר אַן אָפיס 365 שאַרעפּאָינט אַפּ

Intro

I’ve been exploring unit testing and test coverage for JavaScript as I work on a new SharePoint app for SharePoint online in the Office 365 suite.  The obvious research paths led me to Qunit.js and right after that, צו Blanket.js.

QUnit let me set up unit tests and group them into modules.  A module is just a simple way to organize related tests. (I’m not sure I’m using it as intended, but it’s working for me so far with the small set of tests I have thus far defined).

Blanket.js integrates with Qunit and it will show me the actual lines of JavaScript that were – and more importantly – were not actually executed in the course of running the tests.  This is “coverage” – lines that executed are covered by the test while others are not.

Between setting up good test cases and viewing coverage, we can reduce the risk that our code has hidden defects.  Good times.

Qunit

Assuming you have your Visual Studio project set up, start by downloading the JavaScript package from http://qunitjs.com.  Add the JavaScript and corresponding CSS to your solution.  Mine looks like this:

image

Figure 1

ווי איר קענען זען, I was using 1.13.0 at the time I wrote this blog post. Don’t forget to download and add the CSS file.

That out of the way, next step is to create some kind of test harness and reference the Qunit bits.  I’m testing a bunch of functions in a script file called “QuizUtil.js” so I created an HTML page called “QuizUtil_test.html” as shown:

image Figure 2

Here’s the code:

<!DOCTYPE HTML>
<HTML קסמלנס="http://www.w3.org/1999/xhtml">
<head>
    <טיטל>QuizUtil test with Qunit</טיטל>
    <רונג rel="stylesheet" הרעף="../CSS/qunit-1.13.0.css" />
    <שריפט טיפּ="text/javascript" סרק="QuizUtil.js" data-cover></שריפט>
    <שריפט טיפּ ="טעקסט / דזשאַוואַסקריפּט" סרק ="qunit-1.13.0.js"></שריפט>
    <שריפט טיפּ ="טעקסט / דזשאַוואַסקריפּט" סרק ="blanket.min.js"></שריפט>

    <שריפט>
        module("getIDFromLookup");
        פּרובירן("QuizUtil getIDFromLookupField", פונקציע () {
            איז געווען goodValue = "1;#פאולוס גאַלווין";

            equal(getIDFromLookupField(goodValue) + 1, 2), "ID of [" + goodValue + "] + 1 should be 2";
            equal(getIDFromLookupField(undefined), undefined, "Undefined input argument should return undefined result.");
            equal(getIDFromLookupField(""), undefined, "Empty input argument should return an undefined value.");
            equal(getIDFromLookupField("gobbledigood3-thq;dkvn ada;skfja sdjfbvubvqrubqer0873407t534piutheqw;vn"), undefined,"Should always return a result convertible to an Integer");
            equal(getIDFromLookupField("2;#some other person"), "2", "Checking [2;#some other person].");
            equal(getIDFromLookupField("9834524;#long value"), "9834524", "Large value test.");
            notEqual(getIDFromLookupField("5;#anyone", 6), 6, "Testing a notEqual (5 is not equal to 6 for this sample: [5;#anyone]");

        });

        module("htmlEscape");
        פּרובירן("QuizUtil htmlEscape()", פונקציע () {
            equal(htmlEscape("<"), "&לט;", "Escaping a less than operator ('<')");
            equal(htmlEscape("<div class=\"someclass\">Some text</דיוו>"), "&לט;div class=&quot;someclass&quot;&גט;Some text&לט;/דיוו&גט;", "More complex test string.");
        });

        module("getDateAsCaml");
        פּרובירן("QuizUtil getDateAsCaml()", פונקציע () {
            equal(getDateAsCaml(נייַ דאַטע("12/31/2013")), "2013-12-31T:00:00:00", "Testing hard coded date: [12/31/2013]");
            equal(getDateAsCaml(נייַ דאַטע("01/05/2014")), "2014-01-05T:00:00:00", "Testing hard coded date: [01/05/2014]");
            equal(getDateAsCaml(נייַ דאַטע("01/31/2014")), "2014-01-31T:00:00:00", "Testing hard coded date: [01/31/2014]");
            equal(getTodayAsCaml(), getDateAsCaml(נייַ דאַטע()), "getTodayAsCaml() should equal getDateAsCaml(new Date())");
            equal(getDateAsCaml("nonsense value"), undefined, "Try to get the date of a nonsense value.");
            equal(getDateAsCaml(undefined), undefined, "Try to get the date of the [undefined] date.");
        });

        module("getParameterByName");
        פּרובירן("QuizUtil getParameterByName (from the query string)", פונקציע () {
            equal(getParameterByName(undefined), undefined, "Try to get undefined parameter should return undefined.");
            equal(getParameterByName("does not exist"), undefined, "Try to get parameter value when we know the parameter does not exist.");

        });

        module("Cookies");
        פּרובירן("QuizUtil various cookie functions.", פונקציע () {
            equal(setCookie("test", "1", -1), getCookieValue("test"), "Get a cookie I set should work.");
            equal(setCookie("anycookie", "1", -1), ריכטיק, "Setting a valid cooking should return 'true'.");
            equal(setCookie("crazy cookie name !@#$%\"%\\^&*(()?/><.,", "1", -1), ריכטיק, "Setting a bad cookie name should return 'false'.");
            equal(setCookie(undefined, "1", -1), undefined, "Passing undefined as the cookie name.");
            equal(getCookieValue("does not exist"), "", "Cookie does not exist test.");
        });

    </שריפט>
</head>
<גוף>
    <דיוו שייַן="qunit"></דיוו>
    <דיוו שייַן="qunit-fixture"></דיוו>

</גוף>
</HTML>

There are several things happening here:

  1. Referencing my code (QuizUtil.js)
  2. Referencing Qunity.js
  3. Defining some modules (getIDFromLookup, Cookies, און אנדערע)
  4. Placing a <דיוו> whose ID is “qunit”.

דעמאָלט, I just pull up this page and you get something like this:

image

Figure 3

If you look across the top, you have a few options, two of which are interesting:

  • Hide passed tests: Pretty obvious.  Can help your eye just see the problem areas and not a lot of clutter.
  • Module: (drop down): This will filter the tests down to just those groups of tests you want.

As for the tests themselves – a few comments:

  • It goes without saying that you need to write your code such that it’s testable in the first place.  Using the tool can help enforce that discipline. לעמאָשל, I had a function called “getTodayAsCaml()".  This isn’t very testable since it takes no input argument and to test it for equality, we’d need to constantly update the test code to reflect the current date.  I refactored it by adding a data input parameter then passing the current date when I want today’s date in CAML format.
  • The Qunit framework documents its own tests and it seems pretty robust.  It can do simple things like testing for equality and also has support for ajax style calls (both “real” or mocked using your favorite mocker).
  • Going through the process also forces you to think through edge cases – what happens with “undefined” or null is passed into a function.  It makes it dead simple to test these scenarios out.  Good stuff.

Coverage with Blanket.js

Blanket.js complements Qunit by tracking the actual lines of code that execute during the course of running your tests.  It integrates right into Qunit so even though it’s a whole separate app, it plays nicely – it really looks like it’s one seamless app.

This is blanket.js in action:

image Figure 4

image

Figure 5

(You actually have to click on the “Enable coverage” checkbox at the top [see Figure 3] to enable this.)

The highlighted lines in Figure 5 have not been executed by any of my tests, so I need to devise a test that does cause them to execute if I want full coverage.

Get blanket.js working by following these steps:

  1. Download it from http://blanketjs.org/.
  2. Add it to your project
  3. Update your test harness page (QuizUtil_test.html in my case) as follows:
    1. Reference the code
    2. Decorate your <שריפט> reference like this:
    <שריפט טיפּ="text/javascript" סרק="QuizUtil.js" data-cover></שריפט>

Blanket.js picks up the “data-cover” attribute and does its magic.  It hooks into Qunit, updates the UI to add the “Enable coverage” option and voila!

קיצער (TL; DR)

Use Qunit to write your test cases.

  • Download it
  • Add it to your project
  • Write a test harness page
  • Create your tests
    • Refactor some of your code to be testable
    • Be creative!  Think of crazy, impossible scenarios and test them anyway.

Use blanket.js to ensure coverage

  • Make sure Qunit is working
  • Download blanket.js and add it to your project
  • Add it to your test harness page:
    • Add a reference to blanket.js
    • Add a “data-cover” attribute to your <שריפט> פאַרבינדן
  • Run your Qunit tests.

I never did any of this before and had some rudimentary stuff working in a handful of hours. 

Happy testing!

</עק>

undefinedאַבאָנירן צו מיין בלאָג.

גיי מיר אויף טוויטטער בייַ http://www.twitter.com/pagalvin

בפּאָס 2010 און "סופּערסעט”

I was reading one of these pretty generic blah-like articles on BPOS (מייקראָסאָפֿט 'ס וועקסל און שאַרעפּאָינט אין דער וואָלקן) און טאַנגקפאַלי וויידיד דורך צו דער סוף:

אין ווערטער פון אנדערע לעבן-טערמין דעליוועראַבלעס, מייקראָסאָפֿט איז קאָממיטינג צו צושטעלן אין בפּאָס וו.נעקסט געבוירן פּאָווערשעלל סקריפּטינג דורך אַ פּאָווערשעלל ענדפּוינט בויען אויף פּאָווערשעלל ווערסיע 2. Authentication will be done through Online IDs, with a single credential being able to be used for both PowerShell and the portal.Keane echoed the message other Microsoft execs have been voicing at TechEd this week: Cloud capabilities, over time, will  become a superset of what is available on-premises. Currently, the reverse is true, and Microsoft’s Online services offer a subset of the functions available in the software equivalents of each product.

The notion that the cloud will provide more capability than on-premise is new to me. I wonder how true that is going to be in the end.  It feels counterintuitive to me.  I totally get the idea that a lot of companies will move stuff to the cloud (or start off in the cloud) but I normally think they do it because the pro’s (easier admin, SLAs, אאז"ו ו) far outweigh the cons (reduced functionality). 

I’m having a little bit of a hard time believing that cloud offerings will exceed on-prem capabilities.  Multi-tenant is hard and seems like it must force compromises in order to provide good SLA and ease of use…

I’ll probably be eating my words on this.  I remember thinking that no one could possibly need more than 650 mb of data and therefore, the CD was never going to be improved upon.

</עק>

אַבאָנירן צו מיין בלאָג.

גיי מיר אויף טוויטטער בייַ http://www.twitter.com/pagalvin

שאַרעפּאָינט אָנליין און ינפאָפּאַטה

איך קען זייַן די לעצטע מענטש צו פאַרשטיין דעם, אָבער שאַרעפּאָינט אָנליין (וואָס איך אָפֿט הערן מענטשן זאָגן איז אַ געלויבט ווסס) שטיצט ינפאָפּאַטה פאָרמס סערוויסעס.  אַז ס 'שיין שטאַרק שטאָפּן, ספּעציעל קאָנסידערינג אַז יפּ עפעס איז אַ מאָך ענטערפּרייז שטריך און בפּאָס איז עפּעס ווי $ 1.99/מאָנטה פֿאַר 10,000 ניצערס.  אפֿשר עס ס אַ ביסל מער ווי אַז.

אַזוי, שאַרעפּאָינט אָנליין דיפייז גרינג דעפֿיניציע.  עס האט דאָס פאַרנעמונג שטריך, אָבער קיין אַנאַנאַמאַס צוטריט (וואָס אַפֿילו ווסס שטיצט).  איר קענען טאָן עטלעכע טשיקאַווע שטאָפּן מיט זוכן (מאָך-יש, זינט איר קענען דעפינירן פּלאַץ מדרגה סקאָפּעס), אָבער אויב איר דאַרפֿן צוטריט צו די סספּ, איר קענען נישט טאָן עס.  You can play the “on the one hand and on the other” game all night long with this product 🙂

מייקראָסאָפֿט איז רעכט צו מעלדונג אַ נייַ ווערסיע פון ​​ספּ אָנליין אין דער ווייַטער ביסל חדשים.  איך ווונדער וואָס טשודנע כייבריד עס ס 'געגאנגען זייַן?

</עק>

אַבאָנירן צו מיין בלאָג.

גיי מיר אויף טוויטטער בייַ http://www.twitter.com/pagalvin